E
- the class to be chainedpublic final class ChainLink<E> extends Object
The GNU Lesser General Public License for details.
Modifier and Type | Field and Description |
---|---|
private boolean |
head |
private E |
item |
private ChainLink<E> |
left |
private ChainLink<E> |
right |
Constructor and Description |
---|
ChainLink()
Create an empty ChainLink.
|
ChainLink(E item)
Create a ChainLink containing an item.
|
Modifier and Type | Method and Description |
---|---|
void |
addAfter(ChainLink<E> node)
Add this node after the given node.
|
void |
addBefore(ChainLink<E> node)
Add this node before the given node.
|
void |
addFirst(ChainLink<E> anyNode)
Add this node as the head of the chain.
|
void |
addLast(ChainLink<E> anyNode)
Add this node as the tail of the chain.
|
ChainLink<E> |
findHead()
Find the head of the chain.
|
ChainLink<E> |
findTail()
Find the tail of the chain.
|
E |
getItem()
Get the item from this ChainLink.
|
ChainLink<E> |
getLeft()
Get the node to the left of this node.
|
ChainLink<E> |
getRight()
Get the node to the right of this node.
|
boolean |
isHead()
One node is marked as the head of the chain.
|
ChainLink<E> |
locate(E element,
Comparator<E> comparator)
Locate the node or the closest node in the chain using the comparator.
|
void |
remove()
Remove this ChainLink from the chain.
|
void |
setItem(E item)
Set the item for this ChainLink.
|
private E item
private boolean head
public ChainLink()
setItem()
for this to be useful.public ChainLink(E item)
item
- this ChainLink's itempublic void setItem(E item)
item
- this ChainLink's itempublic E getItem()
public boolean isHead()
public ChainLink<E> getLeft()
public ChainLink<E> getRight()
public void remove()
public void addBefore(ChainLink<E> node)
node
- A location in the chain for insertion.public void addAfter(ChainLink<E> node)
node
- A location in the chain for insertion.public ChainLink<E> findHead()
public ChainLink<E> findTail()
public void addFirst(ChainLink<E> anyNode)
anyNode
- any node in the chainpublic void addLast(ChainLink<E> anyNode)
anyNode
- any node in the chainpublic ChainLink<E> locate(E element, Comparator<E> comparator)
element
- The node to look forcomparator
- The comparator that understands the ordering of the list