T - the type of the items on the list.public class DoublyLinked<T extends DoublyLinked<?>>
extends java.lang.Object
DoublyLinkedList.
Unlike a LinkedList, this data structure allows for cheaply removing
items from any position in the list, and inserting them into the list
in positions relative to other items.DoublyLinkedList| Constructor and Description |
|---|
DoublyLinked()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAfter(DoublyLinked<T> link)
Add this item to the list that the provided link is already on,
in the position after that link.
|
void |
addBefore(DoublyLinked<T> link)
Add this item to the list that the provided link is already on,
in the position before that link.
|
T |
getNext(DoublyLinkedList<T> list)
Get the next item on the list.
|
T |
getPrevious(DoublyLinkedList<T> list)
Get the previous item on the list.
|
boolean |
isOnList()
Determine if this item is currently on a list.
|
void |
remove()
Link around this item in the list, clearing this item's next
and previous pointers so it can't affect the list in any way
in the future.
|
void |
removeUnsafe()
Link around this item in the list, without clearing this item's
next and previous pointers.
|
public void removeUnsafe()
public void remove()
public T getNext(DoublyLinkedList<T> list)
list - the listpublic T getPrevious(DoublyLinkedList<T> list)
list - the listpublic void addBefore(DoublyLinked<T> link)
link - the link to add this one beforepublic void addAfter(DoublyLinked<T> link)
link - the link to add this one afterpublic boolean isOnList()
removeUnsafe().