class Minion::SplayTreeMap(K, V)

Defined in:

minion/splay_tree_map.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def [](key : K) #

[View source]
def []=(key, value) #

[View source]
def clear #

[View source]
def delete(key) #

[View source]
def descend_from(node, height_limit, current_height = 0) #

[View source]
def each #

[View source]
def each(&blk : K, V -> ) #

TODO Make this more like other containers in crystal.


[View source]
def each_descend_from(node, &blk : K, V -> ) #

This will recursively walk the whole tree, calling the given block for each node.


[View source]
def find(key : K) #

Find a key without splaying


[View source]
def get(key : K) #

[View source]
def get_root #

[View source]
def has_key?(key) #

[View source]
def height(key) #

[View source]
def height #

[View source]
def keys : Array(K) #

[View source]
def max #

[View source]
def min #

[View source]
def prune #

This will remove all of the leaves at the end of the tree branches. That is, every node that does not have any children. This will tend to remove the least used elements from the tree. This function is expensive, as implemented, as it must walk every node in the tree.

TODO Come up with a more efficient way of getting this same effect.


[View source]
def prune_from(node) #

[View source]
def push(key, value) #

TODO This is surprisingly slow. I assume it is due to the overhead of declaring nodes on the heap. Is there a way to make them work as structs instead of classes?


[View source]
def size #

[View source]
def to_a #

[View source]
def values : Array(V) #

[View source]