All Packages Class Hierarchy This Package Previous Next Index
Class structure.CircularList
java.lang.Object
|
+----structure.CircularList
- public class CircularList
- extends Object
- implements List
A class implementing a singly linked circular list.
CircularList()
- Construct an empty circular list.
add(Object)
- Add an element to the head of the circular list.
addToHead(Object)
- Add an element to the head of the list.
addToTail(Object)
- Add a value to the tail of the circular list.
clear()
- Remove the elements of the list.
contains(Object)
- Check if a list contains an element.
elements()
- Construct an iterator over the elements of the list.
isEmpty()
- Determine if a list is empty.
peek()
- Determine if a list is empty.
remove(Object)
- Remove a value from a list.
removeFromHead()
- Remove a value from the head of the list.
removeFromTail()
- Remove a value from the tail of the list.
size()
- Determine the size of the list.
tailPeek()
- Peek at the last element of the list.
toString()
- Generate a string representation of the list.
CircularList
public CircularList()
- Construct an empty circular list.
- Precondition:
- constructs a new circular list
add
public void add(Object value)
- Add an element to the head of the circular list.
- Postcondition:
- adds value to beginning of list.
- Parameters:
- value - The value to be added to the list.
addToHead
public void addToHead(Object value)
- Add an element to the head of the list.
- Precondition:
- value non-null
- Postcondition:
- adds element to head of list
- Parameters:
- value - The value added to the head of the list.
addToTail
public void addToTail(Object value)
- Add a value to the tail of the circular list.
- Precondition:
- value non-null
- Postcondition:
- adds element to tail of list
- Parameters:
- value - The value to be added.
peek
public Object peek()
- Determine if a list is empty.
- Precondition:
- !isEmpty()
- Postcondition:
- returns value at head of list
- Returns:
- True if there are no elements within the list.
tailPeek
public Object tailPeek()
- Peek at the last element of the list.
- Precondition:
- !isEmpty()
- Postcondition:
- returns value at tail of list
- Returns:
- The value of the last element of the list.
removeFromHead
public Object removeFromHead()
- Remove a value from the head of the list.
- Precondition:
- !isEmpty()
- Postcondition:
- returns and removes value from head of list
- Returns:
- The value removed.
removeFromTail
public Object removeFromTail()
- Remove a value from the tail of the list.
- Precondition:
- !isEmpty()
- Postcondition:
- returns and removes value from tail of list
- Returns:
- The value removed.
contains
public boolean contains(Object value)
- Check if a list contains an element.
- Precondition:
- value != null
- Postcondition:
- returns true if list contains value, else false
- Parameters:
- value - The value sought.
- Returns:
- True iff the value is within the list.
remove
public Object remove(Object value)
- Remove a value from a list.
- Precondition:
- value != null
- Postcondition:
- removes and returns element equal to value, or null
- Parameters:
- value - The value sought.
- Returns:
- The value removed from the list.
size
public int size()
- Determine the size of the list.
- Postcondition:
- returns number of elements in list
- Returns:
- The number of elements in list.
elements
public Iterator elements()
- Construct an iterator over the elements of the list.
Elements are traversed from head to tail.
- Postcondition:
- returns iterator to traverse list elements.
- Returns:
- The iterator associated with the list.
isEmpty
public boolean isEmpty()
- Determine if a list is empty.
- Postcondition:
- returns true if no elements in list
- Returns:
- True iff the list is empty.
clear
public void clear()
- Remove the elements of the list.
- Postcondition:
- removes all elements from list.
toString
public String toString()
- Generate a string representation of the list.
- Postcondition:
- returns a string representing list
- Returns:
- String representing the list.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index