class Pf::Core::Node(T)
- Pf::Core::Node(T)
- Reference
- Object
Overview
Represents a trie node.
Instances of T are stored inline. Meaning if T is a large struct lots and lots of bytes are going to be copied, mostly unnecessarily. Clients will probably want to catch large value Ts and wrap them in a pointer. The notion of "large" depends on the client. It could be an interface or could be a sizeof threshold.
Defined in:
permafrost/core/node.crConstructors
Instance Method Summary
-
#add(probe : IProbeAdd(T)) : Tuple(Bool, Node(T))
Updates or inserts the stored value accepted by probe.
-
#delete(probe : IProbeDelete(T)) : Tuple(Bool, Node(T))
Removes the stored value accepted by probe.
-
#each(& : T -> ) : Nil
Yields each item from this node and from all child nodes.
-
#empty? : Bool
Returns
true
if this node holds no items and points to no children. -
#fetch?(probe : IProbeFetch(T)) : Tuple(T) | Nil
Retrieves the stored value that is accepted by probe.
Constructor Detail
Instance Method Detail
Updates or inserts the stored value accepted by probe.
Returns a tuple where the first element is a boolean indicating whether
the amount of elements in the trie increased by one, and the second element
is the modified version of self
.
If probe wishes mutation, the second element is exactly self
(and the
first element still indicates whether the size increased).
If no changes were made (the stored value is the same as that of probe)
the second element is also exactly self
(and the first element is false
).
Removes the stored value accepted by probe. Returns a tuple where the first
element is a boolean indicating whether the amount of elements in the trie
decreased by one, and the second element is the modified version of self
.
If probe wishes mutation, the second element is exactly self
. If no changes
were made (nothing was removed), the second element is also exactly self
.
Retrieves the stored value that is accepted by probe. Returns the first
stored value accepted by probe, or nil
if probe accepted no values.
The returned value is wrapped in a tuple to differentiate between nil
as value and nil
as absence.