Class DoublyLinkedList
java.lang.Object
org.apache.batik.util.DoublyLinkedList
A simple Doubly Linked list class, designed to avoid
O(n) behaviour on insert and delete.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBasic doubly linked list node interface. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int index, DoublyLinkedList.Node nde) voidadd(DoublyLinkedList.Node nde) Addsndeto the head of the list.voidempty()Removes all elements from the list.getHead()Get the current head elementintgetSize()Returns the number of elements currently in the list.getTail()Get the current tail elementpop()Removes 'head' from list and returns it.voidAddsndeto tail of listvoidRemoves nde from the list it is part of (should be this one, otherwise results are undefined).voidMovesndeto the head of the list (equivilent to remove(nde); add(nde); but faster.voidAddsndeto head of listunpush()Removes 'tail' from list and returns it.
-
Constructor Details
-
DoublyLinkedList
public DoublyLinkedList()
-
-
Method Details
-
getSize
public int getSize()Returns the number of elements currently in the list. -
empty
public void empty()Removes all elements from the list. -
getHead
Get the current head element- Returns:
- The current 'first' element in list.
-
getTail
Get the current tail element- Returns:
- The current 'last' element in list.
-
touch
Movesndeto the head of the list (equivilent to remove(nde); add(nde); but faster. -
add
-
add
Addsndeto the head of the list. In perl this is called an 'unpop'.ndeshould not currently be part of any list.- Parameters:
nde- the node to add to the list.
-
remove
Removes nde from the list it is part of (should be this one, otherwise results are undefined). If nde is the current head element, then the next element becomes head, if there are no more elements the list becomes empty.- Parameters:
nde- node to remove.
-
pop
Removes 'head' from list and returns it. Returns null if list is empty.- Returns:
- current head element, next element becomes head.
-
unpush
Removes 'tail' from list and returns it. Returns null if list is empty.- Returns:
- current tail element.
-
push
Addsndeto tail of list -
unpop
Addsndeto head of list
-