|
Jive Forums API (5.5.20.2-oracle) Developer Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jivesoftware.util.CircularLinkedList
public class CircularLinkedList
Simple circular LinkedList allowing the marking of a position, reset of position, and pass count.
The circular list provides several tools for 'spinning' the circular list. The circular list is best thought of as an iterator on the circular list without a head or tail. Adds are conducted at the current list position and nodes lack indexes. Call mark() to mark the current node as a 'zero' position. When the next list item is called, the pass count is incremented when the current position is equal to the marked position. This allows users of the circular list to mark and spin around the circular list, checking how many times they go around the list.
Constructor Summary | |
---|---|
CircularLinkedList()
Creates a new linked list. |
|
CircularLinkedList(java.lang.Object firstItem)
Creates a new linked list. |
Method Summary | |
---|---|
void |
add(java.lang.Object item)
Add the given item so the following call to next() will return the item. |
void |
clear()
Erases all elements in the list and re-initializes it. |
boolean |
contains(java.lang.Object item)
Returns true if the given object is contained in this list. |
int |
getPassCount()
Obtain the number of times the iteration of the list has passed the mark. |
boolean |
isEmpty()
Returns true if the circular linked list is empty. |
void |
mark()
Resets the pass count to zero and sets the mark to the current list position. |
java.lang.Object |
next()
Advances the list to the next item and returns the item found or null if no items are in the list. |
java.lang.Object |
prev()
Moves the list to the previous item and returns the item found or null if no items are in the list. |
void |
remove()
Removes the current item (the item last returned by next() or prev()). |
void |
remove(java.lang.Object item)
Removes the first item found that matches equals() on the given item. |
void |
setNext(java.lang.Object item)
Sets the object that will be return by next() to the given value. |
void |
setPrev(java.lang.Object item)
Sets the object that will be return by prev() to the given value. |
int |
size()
Returns the number of items in the list. |
java.lang.String |
toString()
Returns a String representation of the linked list with a comma delimited list of all the elements in the list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CircularLinkedList()
public CircularLinkedList(java.lang.Object firstItem)
Method Detail |
---|
public int getPassCount()
Obtain the number of times the iteration of the list has passed the mark.
The passcount is reset using the mark() method.
public void mark()
Resets the pass count to zero and sets the mark to the current list position.
public void add(java.lang.Object item)
Add the given item so the following call to next() will return the item.
item
- The item to be addedpublic void setNext(java.lang.Object item)
Sets the object that will be return by next() to the given value.
If no next value exists, nothing happens (no new items will be added.
item
- The item to be setpublic void setPrev(java.lang.Object item)
Sets the object that will be return by prev() to the given value.
If no prev value exists, nothing happens (no new items will be added.
item
- The item to be setpublic java.lang.Object next()
Advances the list to the next item and returns the item found or null if no items are in the list.
public java.lang.Object prev()
Moves the list to the previous item and returns the item found or null if no items are in the list.
public void clear()
public void remove(java.lang.Object item)
Removes the first item found that matches equals() on the given item.
If this list does not contain the element, it is unchanged. More formally, removes the first element found by calling next() such that (item==null ? get(i)==null : item.equals(get(i))) (if such an element is found before making a complete trip around the circular list).
item
- the item to removepublic void remove()
Removes the current item (the item last returned by next() or prev()).
public boolean contains(java.lang.Object item)
Returns true if the given object is contained in this list.
item
- The item to check for existance
public int size()
Returns the number of items in the list.
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isEmpty()
Returns true if the circular linked list is empty.
|
Jive Forums Project Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |