Interface LoopADT<E>


public interface LoopADT<E>

A Loop ADT is a circular sequence of items. A Loop has a current item and the ability to move forward or backwards. A Loop can be modified by removing the current item or by adding an item before the current item.


Method Summary
 void add(E item)
          Adds the given item immediately before the current item.
 E getCurrent()
          Returns the current item.
 boolean isEmpty()
          Determines if this Loop is empty, i.e., contains no items.
 java.util.Iterator<E> iterator()
          Returns an iterator for this Loop.
 void next()
          Advances current forward one item resulting in the item that is immediately after the current item becoming the current item.
 void previous()
          Moves current backwards one item resulting in the item that is immediately before the current item becoming the current item.
 E removeCurrent()
          Removes and returns the current item.
 int size()
          Returns the number of items in this Loop.
 

Method Detail

add

void add(E item)
Adds the given item immediately before the current item. After the new item has been added, the new item becomes the current item.

Parameters:
item - the item to add

getCurrent

E getCurrent()
             throws EmptyLoopException
Returns the current item. If the Loop is empty, an EmptyLoopException is thrown.

Returns:
the current item
Throws:
EmptyLoopException - if the Loop is empty

removeCurrent

E removeCurrent()
                throws EmptyLoopException
Removes and returns the current item. The item immediately after the removed item then becomes the current item. If the Loop is empty initially, an EmptyLoopException is thrown.

Returns:
the removed item
Throws:
EmptyLoopException - if the Loop is empty

next

void next()
Advances current forward one item resulting in the item that is immediately after the current item becoming the current item.


previous

void previous()
Moves current backwards one item resulting in the item that is immediately before the current item becoming the current item.


isEmpty

boolean isEmpty()
Determines if this Loop is empty, i.e., contains no items.

Returns:
true if the Loop is empty; false otherwise

size

int size()
Returns the number of items in this Loop.

Returns:
the number of items in this Loop

iterator

java.util.Iterator<E> iterator()
Returns an iterator for this Loop.

Returns:
an iterator for this Loop