class FibonacciHeap::Node

A single node in a Fibonacci Heap.

Contains a key and optional value that can be any arbitrary object. The key will be used to sort nodes so that the key of a node is greater than or equal to the key of its parent.

Defaults to storing the key as the value.

Attributes

child_list[RW]

Return the list of child nodes for this node.

degree[RW]

Return the degree of this node.

key[RW]

Return the key of the node.

left[RW]

Return the node previous to this one.

mark[RW]

Return whether this node is marked or not.

next[RW]

Return the node next to this one.

p[RW]

Return the parent of this node or nil if there is none.

prev[RW]

Return the node previous to this one.

right[RW]

Return the node next to this one.

value[RW]

Return the value of the node.

Public Class Methods

new(key, value = key) click to toggle source

Return a new node with the given key and optional value.

The key and value can be any arbitrary object.

The node's next and previous pointers will default to itself.

Defaults the value to the key.

# File lib/fibonacci_heap/node.rb, line 43
def initialize(key, value = key)
  @key = key
  @value = value
  @next = self
  @prev = self
end

Public Instance Methods

inspect() click to toggle source
# File lib/fibonacci_heap/node.rb, line 50
def inspect
  %(#<#{self.class} key=#{key.inspect} value=#{value.inspect}>)
end