View Source PairingHeap.Node (pairing_heap v0.3.0)
Defines the PairingHeap.Node
struct and functions for creating and
combining nodes.
The functions PairingHeap.Node.merge/3
and ParingHeap.Node.merge/2
combine pairs and lists of nodes, respectively, in a way that preserves the
heap property. Both of these functions take as an argument the predicate
ordered?/2
, where ordered?.(node1, node2)
returns true
if node1
is correctly ordered relatively to node2
according to the heap property.
Summary
Functions
Return a list of all items in the tree defined by the given node.
Return true
if any node in the tree defined by node
contains item
, and
false
otherwise.
Merge a list of nodes into a single node that satisfies the heap property.
Link a pair of nodes into a single node that satisfies the heap property.
Create a new pairing-heap node with an item and a list of zero or more child nodes.
Types
Functions
Return a list of all items in the tree defined by the given node.
@spec member?(t(), any(), ordered_fn()) :: boolean()
Return true
if any node in the tree defined by node
contains item
, and
false
otherwise.
@spec merge([t()], ordered_fn()) :: t()
Merge a list of nodes into a single node that satisfies the heap property.
The pairwise recursive merger follows the algorithm described in the
original paper,
which has O(log n)
amortized run time.
@spec merge(t(), t(), ordered_fn()) :: t()
Link a pair of nodes into a single node that satisfies the heap property.
One of the given nodes is a parent and the other is the child, as determined
by ordered?/2
. The child node is prepended to the list of child nodes for
the parent. No other maintenance is required for the individual nodes in a
pairing heap. It follows that meld
runs in O(1)
time.
Create a new pairing-heap node with an item and a list of zero or more child nodes.