Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1.  
  2. /**
  3. * An ordered list of items.
  4. */
  5. public interface ItemList<E> {
  6. /**
  7. * Append an item to the end of the list
  8. *
  9. * @param item – item to be appended
  10. */
  11.  
  12.  
  13. public void append(E item) {
  14.  
  15. }
  16.  
  17. /**
  18. * Insert an item at a specified index
  19. *
  20. * @param index – index where to insert the item
  21. * @param item – item to be inserted
  22. * @throw IndexOutOfBoundsException if index is < 0 or >= no of items
  23. */
  24. public void insert(int index, E item);
  25.  
  26. /**
  27. * Remove all items from the list
  28. */
  29. public void clear();
  30.  
  31. /**
  32. * Return an item at a specified index
  33. *
  34. * @param index – index of the item to return
  35. * @return the item at the specified index
  36. * @throw IndexOutOfBoundsException if index is < 0 or >= no of items
  37. */
  38. public E get(int index) {
  39.  
  40. }
  41.  
  42.  
  43.  
  44. /**
  45. * Return the index of the first occurrence of an item in the list.
  46. *
  47. * @return index of the first occurrence in the list, -1 if not found
  48. */
  49. public int indexOf(E item);
  50.  
  51.  
  52. /**
  53. * Return an ItemIterator to iterate over items in the list.
  54. *
  55. * @return an ItemIterator to iterate over items in the list
  56. */
  57. public ItemIterator<E> iterator();
  58.  
  59. /**
  60. * Remove an item at a specified index
  61. *
  62. * @param index – index of the item to be removed
  63. * @return the removed item
  64. * @throw IndexOutOfBoundsException if index is < 0 or >= no of items
  65. */
  66. public E remove(int index);
  67.  
  68. /**
  69. * Remove the first occurrence of an item in the list.
  70. *
  71. * @item – item to be removed
  72. * @return true if an occurrence of the item was found and removed,
  73. * otherwise false
  74. */
  75. public boolean remove(E item);
  76.  
  77.  
  78.  
  79. /**
  80. * Return the number of items currently in the list
  81. *
  82. * @return the number of items in the list
  83. */
  84. public int noItems();
  85. }
  86.  
  87. /**
  88. * An iterator over an ItemList
  89. */
  90. public interface ItemIterator<E> {
  91. /**
  92. * Return true if the iteration has more items
  93. *
  94. * @return true if the iteration has more items, otherwise false
  95. */
  96. public boolean hasMoreItems();
  97.  
  98. /**
  99. * Return next item from iteration
  100. *
  101. * @return next item from iteration
  102. * @throw NoSuchElementException if the iteration has no more items
  103. */
  104. public E nextItem();
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement