License:
see license.txt
- struct
Link
(V);
- Linked-list node that is used in various collection classes.
- alias
Node
;
- convenience alias
- V
value
;
- the
value
that is represented by this link node.
- Node
prepend
(Node n);
- insert the given node between this node and prev. This updates all
pointers in this, n, and prev.
returns this to allow for chaining.
- Node
append
(Node n);
- insert the given node between this node and next. This updates all
pointers in this, n, and next.
returns this to allow for chaining.
- Node
unlink
();
- remove this node from the list. If prev or next is non-null, their
pointers are updated.
returns this to allow for chaining.
- void
attach
(Node first, Node second);
- link two nodes together.
- uint
count
(Node endNode = null);
-
count
how many nodes until endNode.
- struct
LinkHead
(V,alias Allocator = DefaultAllocator);
- This struct uses a Link(V) to keep track of a link-list of values.
The implementation uses a dummy link node to be the head and tail of the
list. Basically, the list is circular, with the dummy node marking the
end/beginning.
- alias
Node
;
- Convenience alias
- alias
allocator
;
- Convenience alias
- allocator
alloc
;
- The allocator for this link head
- Node
end
;
- The node that denotes the
end
of the list
- uint
count
;
- The number of nodes in the list
- Node
begin
();
- Get the first valid node in the list
- void
setup
();
- Initialize the list
- Node
remove
(Node n);
- Remove a node from the list, returning the next node in the list, or
end if the node was the last one in the list. O(1) operation.
- template
sort
(Comparator)
-
sort
the list according to the given compare function
- void
sort
(Comparator comp);
-
sort
the list according to the given compare function
- Node
remove
(Node first, Node last);
- Remove all the nodes from first to last. This is an O(n) operation.
- Node
insert
(Node before, V v);
- Insert the given value before the given node. Use
insert
(end, v) to
add to the end of the list, or to an empty list. O(1) operation.
- void
clear
();
- Remove all nodes from the list
- void
copyTo
(ref LinkHead target, bool copyNodes = true);
- Copy this list to the target.
- Node
allocate
();
- Allocate a new node
- Node
allocate
(V v);
- Allocate a new node, then set the value to v
|