Class IntrusiveDoublyLinkedStructureBase<VALUE_TYPE>
java.lang.Object
com.illumon.util.datastructures.linked.IntrusiveDoublyLinkedStructureBase<VALUE_TYPE>
- Direct Known Subclasses:
IntrusiveDoublyLinkedQueue
public abstract class IntrusiveDoublyLinkedStructureBase<VALUE_TYPE> extends Object
Circular doubly-linked structure base, based loosely on DoubleLinkedCircularListNode and
IntrusiveChainedHashAdapter. Intended as a utility for building other structures.
Note that "unlinked" nodes should have themselves as their next and previous nodes.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
IntrusiveDoublyLinkedStructureBase.Adapter<NODE_TYPE>
Adapter interface for nodes with intrusively-stored previous and next nodes. -
Constructor Summary
Constructors Modifier Constructor Description protected
IntrusiveDoublyLinkedStructureBase(IntrusiveDoublyLinkedStructureBase.Adapter<VALUE_TYPE> adapter)
Constructor, for sub-class use only. -
Method Summary
Modifier and Type Method Description protected boolean
compatible(IntrusiveDoublyLinkedStructureBase<VALUE_TYPE> other)
Is the other data structure compatible with this one? This is true if and only if it's the same class, with the same adapter instance.protected VALUE_TYPE
getNext(VALUE_TYPE node)
Get the next node after the input node.protected VALUE_TYPE
getPrev(VALUE_TYPE node)
Get the previous node before the input node.protected boolean
isLinked(VALUE_TYPE node)
Test if a node is part of a structure.protected VALUE_TYPE
linkAfter(VALUE_TYPE node, VALUE_TYPE other)
Insert a node after another node.protected VALUE_TYPE
linkBefore(VALUE_TYPE node, VALUE_TYPE other)
Insert a node before another node.protected void
setNext(VALUE_TYPE node, VALUE_TYPE other)
Set the input node's next node.protected void
setPrev(VALUE_TYPE node, VALUE_TYPE other)
Set the input node's previous node.protected VALUE_TYPE
unlink(VALUE_TYPE node)
Remove a node from a structure.
-
Constructor Details
-
IntrusiveDoublyLinkedStructureBase
protected IntrusiveDoublyLinkedStructureBase(@NotNull IntrusiveDoublyLinkedStructureBase.Adapter<VALUE_TYPE> adapter)Constructor, for sub-class use only.- Parameters:
adapter
- The adapter for updating a node's next and previous nodes.
-
-
Method Details
-
getNext
Get the next node after the input node.- Parameters:
node
- The input node- Returns:
- The input node's next node
-
setNext
Set the input node's next node.- Parameters:
node
- The input nodeother
- The input node's new next node
-
getPrev
Get the previous node before the input node.- Parameters:
node
- The input node- Returns:
- The input node's previous node
-
setPrev
Set the input node's previous node.- Parameters:
node
- The input nodeother
- The input node's new previous node
-
isLinked
Test if a node is part of a structure.- Parameters:
node
- The node to test- Returns:
- Whether the node is part of a structure (i.e. if its next node is not itself)
-
linkBefore
@NotNull protected final VALUE_TYPE linkBefore(@NotNull VALUE_TYPE node, @NotNull VALUE_TYPE other)Insert a node before another node.- Parameters:
node
- The node to insertother
- The node to insert before- Returns:
- node
-
linkAfter
Insert a node after another node.- Parameters:
node
- The node to insertother
- The node to insert after- Returns:
- node
-
unlink
Remove a node from a structure.- Parameters:
node
- The node to remove- Returns:
- node
-
compatible
Is the other data structure compatible with this one? This is true if and only if it's the same class, with the same adapter instance.- Parameters:
other
- The other data structure- Returns:
- Whether other is compatible
-