ListADT.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * ListADT defines the interface to a general list collection. Specific
  3. * types of lists will extend this interface to complete the
  4. * set of necessary operations.
  5. * @author Dr. Lewis
  6. * @author Dr. Chase
  7. * @version 1.0, 08/13/08
  8. */
  9. import java.util.Iterator;
  10. public interface ListADT<T>
  11. {
  12. /**
  13. * Removes and returns the first element from this list.
  14. *
  15. * @return the first element from this list
  16. */
  17. public T removeFirst ();
  18. /**
  19. * Removes and returns the last element from this list.
  20. *
  21. * @return the last element from this list
  22. */
  23. public T removeLast ();
  24. /**
  25. * Removes and returns the specified element from this list.
  26. *
  27. * @param element the element to be removed from the list
  28. */
  29. public T remove (T element);
  30. /**
  31. * Returns a reference to the first element in this list.
  32. *
  33. * @return a reference to the first element in this list
  34. */
  35. public T first ();
  36. /**
  37. * Returns a reference to the last element in this list.
  38. *
  39. * @return a reference to the last element in this list
  40. */
  41. public T last ();
  42. /**
  43. * Returns true if this list contains the specified target element.
  44. *
  45. * @param target the target that is being sought in the list
  46. * @return true if the list contains this element
  47. */
  48. public boolean contains (T target);
  49. /**
  50. * Returns true if this list contains no elements.
  51. *
  52. * @return true if this list contains no elements
  53. */
  54. public boolean isEmpty();
  55. /**
  56. * Returns the number of elements in this list.
  57. *
  58. * @return the integer representation of number of elements in this list
  59. */
  60. public int size();
  61. /**
  62. * Returns an iterator for the elements in this list.
  63. *
  64. * @return an iterator over the elements in this list
  65. */
  66. public Iterator<T> iterator();
  67. /**
  68. * Returns a string representation of this list.
  69. *
  70. * @return a string representation of this list
  71. */
  72. public String toString();
  73. }