Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * An ordered list of items.
- */
- public interface ItemList<E> {
- /**
- * Append an item to the end of the list
- *
- * @param item – item to be appended
- */
- public void append(E item) {
- }
- /**
- * Insert an item at a specified index
- *
- * @param index – index where to insert the item
- * @param item – item to be inserted
- * @throw IndexOutOfBoundsException if index is < 0 or >= no of items
- */
- public void insert(int index, E item);
- /**
- * Remove all items from the list
- */
- public void clear();
- /**
- * Return an item at a specified index
- *
- * @param index – index of the item to return
- * @return the item at the specified index
- * @throw IndexOutOfBoundsException if index is < 0 or >= no of items
- */
- public E get(int index) {
- }
- /**
- * Return the index of the first occurrence of an item in the list.
- *
- * @return index of the first occurrence in the list, -1 if not found
- */
- public int indexOf(E item);
- /**
- * Return an ItemIterator to iterate over items in the list.
- *
- * @return an ItemIterator to iterate over items in the list
- */
- public ItemIterator<E> iterator();
- /**
- * Remove an item at a specified index
- *
- * @param index – index of the item to be removed
- * @return the removed item
- * @throw IndexOutOfBoundsException if index is < 0 or >= no of items
- */
- public E remove(int index);
- /**
- * Remove the first occurrence of an item in the list.
- *
- * @item – item to be removed
- * @return true if an occurrence of the item was found and removed,
- * otherwise false
- */
- public boolean remove(E item);
- /**
- * Return the number of items currently in the list
- *
- * @return the number of items in the list
- */
- public int noItems();
- }
- /**
- * An iterator over an ItemList
- */
- public interface ItemIterator<E> {
- /**
- * Return true if the iteration has more items
- *
- * @return true if the iteration has more items, otherwise false
- */
- public boolean hasMoreItems();
- /**
- * Return next item from iteration
- *
- * @return next item from iteration
- * @throw NoSuchElementException if the iteration has no more items
- */
- public E nextItem();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement