diff --git a/docs/index.html b/docs/index.html index af5f762..823e429 100644 --- a/docs/index.html +++ b/docs/index.html @@ -74,6 +74,8 @@
A splay tree is a type of binary search tree that self organizes so that the most frequently accessed items tend to be towards the root of the tree, where they can be accessed more quickly.
@@ -92,7 +94,7 @@This is useful if the data structure is being used to implement a cache, as it can be used to control the size of the cache while generaly keeping the @@ -136,7 +138,7 @@
Full documentation can be found at: https://wyhaines.github.io/splay_tree_map.cr/index.html
+Full documentation can be found at: https://wyhaines.github.io/splay_tree_map.cr/index.html
require "splay_tree_map"
@@ -154,7 +156,7 @@ Zips two arrays into a SplayTreeMap
, taking keys from ary1 and values from ary2.
Creates a new empty SplayTreeMap
with a block that is called when a key is missing from the tree.
Creates a new empty SplayTreeMap
with a block that is called when a key is missing from the tree.
Creates a new SplayTreeMap
, populating it with values from the Enumerable or the Iterable seed object, and with a default return value for any missing key.
Creates a new empty SplayTreeMap
with a default return value for any missing key.
Compares two SplayTreeMaps.
","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"SplayTreeMap(L, W)"}],"args_string":"(other : SplayTreeMap(L, W)) forall L, W","source_link":null,"def":{"name":"<=>","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"SplayTreeMap(L, W)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"cmp = surface_cmp(other)\nif cmp == 0\nelse\n return cmp\nend\nme_iter = each\nother_iter = other.each\ncmp = 0\nloop do\n me_entry = me_iter.next?\n other_entry = other_iter.next?\n if me_entry.nil? || other_entry.nil?\n return 0\n else\n cmp = (me_entry.as(::Tuple(K, V))) <=> (other_entry.as(::Tuple(L, W)))\n if cmp == 0\n else\n return cmp\n end\n end\nend\n"}},{"id":"[](key:K)-instance-method","html_id":"[](key:K)-instance-method","name":"[]","doc":"Searches for the given *key* in the tree and returns the associated value.\nIf the key is not in the tree, a KeyError will be raised.\n\n```\nstm = SplayTreeMap(String, String).new\nstm[\"foo\"] = \"bar\"\nstm[\"foo\"] # => \"bar\"\n\nstm = SplayTreeMap(String, String).new(\"bar\")\nstm[\"foo\"] # => \"bar\"\n\nstm = SplayTreeMap(String, String).new { \"bar\" }\nstm[\"foo\"] # => \"bar\"\n\nstm = Hash(String, String).new\nstm[\"foo\"] # raises KeyError\n```","summary":"Searches for the given key in the tree and returns the associated value.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"args_string":"(key : K)","source_link":null,"def":{"name":"[]","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(get(key)).as(V)"}},{"id":"[]=(key,value)-instance-method","html_id":"[]=(key,value)-instance-method","name":"[]=","doc":"Create a key/value association.\n\n```\nstm[\"this\"] = \"that\"\n```","summary":"Create a key/value association.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(key, value)","source_link":null,"def":{"name":"[]=","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"push(key, value)\nvalue\n"}},{"id":"[]?(key:K)-instance-method","html_id":"[]?(key:K)-instance-method","name":"[]?","doc":"Returns the value for the key given by *key*.\nIf not found, returns `nil`. This ignores the default value set by `Hash.new`.\n\n```\nstm = SplayTreeMap(String, String).new\nstm[\"foo\"]? # => \"bar\"\nstm[\"bar\"]? # => nil\n\nstm = SplayTreeMap(String, String).new(\"bar\")\nstm[\"foo\"]? # => nil\n```","summary":"Returns the value for the key given by key.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"args_string":"(key : K)","source_link":null,"def":{"name":"[]?","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"get(key: key, raise_exception: false)"}},{"id":"clear-instance-method","html_id":"clear-instance-method","name":"clear","doc":"Resets the state of the `SplayTreeMap`, clearing all key/value associations.","summary":"Resets the state of the SplayTreeMap
, clearing all key/value associations.
Returns new SplayTreeMap
that has all of the nil
values and their associated keys removed.
Removes all nil
values from self
.
Deletes the key-value pair and returns the value, else yields key with given block.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key, &)","source_link":null,"def":{"name":"delete","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"value = delete_impl(key)\nvalue != Unk ? value : yield key\n"}},{"id":"delete(key)-instance-method","html_id":"delete(key)-instance-method","name":"delete","doc":"Deletes the key-value pair and returns the value, otherwise returns `nil`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.delete(\"foo\") # => \"bar\"\nstm.fetch(\"foo\", nil) # => nil\n```","summary":"Deletes the key-value pair and returns the value, otherwise returns nil
.
DEPRECATED This is just #reject!
by another name.
Traverses the depth of a structure and returns the value, otherwise raises KeyError
.
Traverses the depth of a structure and returns the value.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"subkeys","doc":null,"default_value":"","external_name":"subkeys","restriction":""}],"args_string":"(key : K, *subkeys)","source_link":null,"def":{"name":"dig?","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"subkeys","doc":null,"default_value":"","external_name":"subkeys","restriction":""}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (value = self[key]?) && (value.responds_to?(:\"dig?\"))\n value.dig?(*subkeys)\nend"}},{"id":"dup-instance-method","html_id":"dup-instance-method","name":"dup","doc":"Duplicates a `SplayTreeMap`.\n\n```\nstm_a = {\"foo\" => \"bar\"}\nstm_b = hash_a.dup\nstm_b.merge!({\"baz\" => \"qux\"})\nstm_a # => {\"foo\" => \"bar\"}\n```","summary":"Duplicates a SplayTreeMap
.
Calls the given block for each key/value pair, passing the pair into the block.
","abstract":false,"args":[],"args_string":"(& : Tuple(K, V) -> ) : Nil","source_link":null,"def":{"name":"each","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"","doc":null,"default_value":"","external_name":"","restriction":"(::Tuple(K, V) -> )"},"return_type":"Nil","visibility":"Public","body":"iter = EntryIterator(K, V).new(self)\nwhile true\n entry = iter.next\n if entry == Iterator.stop\n break\n end\n yield entry.as(::Tuple(K, V))\nend\n"}},{"id":"each:EntryIterator(K,V)-instance-method","html_id":"each:EntryIterator(K,V)-instance-method","name":"each","doc":"Returns an iterator which can be used to access all of the elements in the tree.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"fob\" => \"baz\", \"qix\" => \"qux\"})\n\nset = [] of Tuple(String, String)\niterator = stm.each\nwhile entry = iterator.next\n set << entry\nend\n\nset # => [{\"fob\" => \"baz\"}, {\"foo\" => \"bar\", \"qix\" => \"qux\"}]\n","summary":"Returns an iterator which can be used to access all of the elements in the tree.
","abstract":false,"args":[],"args_string":" : EntryIterator(K, V)","source_link":null,"def":{"name":"each","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"EntryIterator(K, V)","visibility":"Public","body":"EntryIterator(K, V).new(self)"}},{"id":"each_key-instance-method","html_id":"each_key-instance-method","name":"each_key","doc":"Returns an iterator over the SplayTreeMap keys.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\niterator = stm.each_key\n\nkey = iterator.next\nkey # => \"foo\"\n\nkey = iterator.next\nkey # => \"baz\"\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Returns an iterator over the SplayTreeMap keys.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"each_key","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"KeyIterator(K, V).new(self)"}},{"id":"each_key(&)-instance-method","html_id":"each_key(&)-instance-method","name":"each_key","doc":"Calls the given block for each key-value pair and passes in the key.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.each_key do |key|\n key # => \"foo\"\nend\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Calls the given block for each key-value pair and passes in the key.
","abstract":false,"args":[],"args_string":"(&)","source_link":null,"def":{"name":"each_key","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |key, value|\n yield key\nend"}},{"id":"each_value-instance-method","html_id":"each_value-instance-method","name":"each_value","doc":"Returns an iterator over the hash values.\nWhich behaves like an `Iterator` consisting of the value's types.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\niterator = stm.each_value\n\nvalue = iterator.next\nvalue # => \"bar\"\n\nvalue = iterator.next\nvalue # => \"qux\"\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Returns an iterator over the hash values.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"each_value","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"ValueIterator(K, V).new(self)"}},{"id":"each_value(&)-instance-method","html_id":"each_value(&)-instance-method","name":"each_value","doc":"Calls the given block for each key-value pair and passes in the value.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.each_value do |value|\n value # => \"bar\"\nend\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Calls the given block for each key-value pair and passes in the value.
","abstract":false,"args":[],"args_string":"(&)","source_link":null,"def":{"name":"each_value","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |key, value|\n yield value\nend"}},{"id":"empty?-instance-method","html_id":"empty?-instance-method","name":"empty?","doc":"Returns true of the tree contains no key/value pairs.\n\n```\nstm = SplayTreeMap(Int32, Int32).new\nstm.empty? # => true\nstm[1] = 1\nstm.empty? # => false\n```\n","summary":"Returns true of the tree contains no key/value pairs.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"empty?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@size == 0"}},{"id":"fetch(key,&)-instance-method","html_id":"fetch(key,&)-instance-method","name":"fetch","doc":"Returns the value for the key given by *key*, or when not found calls the given block with the key.\nThis ignores the default value set by `SplayTreeMap.new`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.fetch(\"foo\") { \"default value\" } # => \"bar\"\nstm.fetch(\"bar\") { \"default value\" } # => \"default value\"\nstm.fetch(\"bar\") { |key| key.upcase } # => \"BAR\"\n```","summary":"Returns the value for the key given by key, or when not found calls the given block with the key.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key, &)","source_link":null,"def":{"name":"fetch","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"value = get_impl(key)\nvalue != Unk ? value : yield key\n"}},{"id":"fetch(key,default)-instance-method","html_id":"fetch(key,default)-instance-method","name":"fetch","doc":"Returns the value for the key given by *key*, or when not found the value given by *default*.\nThis ignores the default value set by `SplayTreeMap.new`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.fetch(\"foo\", \"foo\") # => \"bar\"\nstm.fetch(\"bar\", \"foo\") # => \"foo\"\n```","summary":"Returns the value for the key given by key, or when not found the value given by default.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"default","doc":null,"default_value":"","external_name":"default","restriction":""}],"args_string":"(key, default)","source_link":null,"def":{"name":"fetch","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"default","doc":null,"default_value":"","external_name":"default","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"fetch(key) do\n default\nend"}},{"id":"has_key?(key):Bool-instance-method","html_id":"has_key?(key):Bool-instance-method","name":"has_key?","doc":"Return a boolean value indicating whether the given key can be found in the tree.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2})\nstm.has_key?(\"a\") # => true\nstm.has_key?(\"c\") # => false\n```\n","summary":"Return a boolean value indicating whether the given key can be found in the tree.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key) : Bool","source_link":null,"def":{"name":"has_key?","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":"(get_impl(key)) == Unk ? false : true"}},{"id":"has_value?(value):Bool-instance-method","html_id":"has_value?(value):Bool-instance-method","name":"has_value?","doc":"Return a boolean value indicating whether the given value can be found in the tree.\nThis is potentially slow as it requires scanning the tree until a match is found or\nthe end of the tree is reached.\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2})\nstm.has_value?(\"2\") # => true\nstm.has_value?(\"4\") # => false\n```\n","summary":"Return a boolean value indicating whether the given value can be found in the tree.
","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value) : Bool","source_link":null,"def":{"name":"has_value?","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":"self.each do |k, v|\n if v == value\n return true\n end\nend\nfalse\n"}},{"id":"height-instance-method","html_id":"height-instance-method","name":"height","doc":"Return the height of the current tree.","summary":"Return the height of the current tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"height","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"height_recursive(@root)"}},{"id":"height(key):Int32?-instance-method","html_id":"height(key):Int32?-instance-method","name":"height","doc":"Return the height at which a given key can be found.","summary":"Return the height at which a given key can be found.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key) : Int32?","source_link":null,"def":{"name":"height","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32 | ::Nil","visibility":"Public","body":"node = @root\nif node.nil?\n return nil\nend\nh = 0\nloop do\n if node\n else\n return nil\n end\n cmp = key <=> node.key\n if cmp == -1\n h = h + 1\n node = node.left\n else\n if cmp == 1\n h = h + 1\n node = node.right\n else\n return h\n end\n end\nend\n"}},{"id":"key_for(value)-instance-method","html_id":"key_for(value)-instance-method","name":"key_for","doc":"Returns a key with the given *value*, else raises `KeyError`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nstm.key_for(\"bar\") # => \"foo\"\nstm.key_for(\"qux\") # => \"baz\"\nstm.key_for(\"foobar\") # raises KeyError\n```","summary":"Returns a key with the given value, else raises KeyError
.
Returns a key with the given value, else yields value with the given block.
","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value, &)","source_link":null,"def":{"name":"key_for","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |k, v|\n if v == value\n return k\n end\nend\nyield value\n"}},{"id":"key_for?(value)-instance-method","html_id":"key_for?(value)-instance-method","name":"key_for?","doc":"Returns a key with the given *value*, else `nil`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nstm.key_for?(\"bar\") # => \"foo\"\nstm.key_for?(\"qux\") # => \"baz\"\nstm.key_for?(\"foobar\") # => nil\n```","summary":"Returns a key with the given value, else nil
.
Returns an array of all keys in the tree.
","abstract":false,"args":[],"args_string":" : Array(K)","source_link":null,"def":{"name":"keys","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(K)","visibility":"Public","body":"a = [] of K\neach do |k, v|\n a << k\nend\na\n"}},{"id":"last-instance-method","html_id":"last-instance-method","name":"last","doc":"Returns the last key/value pair in the tree.","summary":"Returns the last key/value pair in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"last","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root\nelse\n return nil\nend\nn = @root\nwhile n && n.right\n n = n.right\nend\n{n.not_nil!.key, n.not_nil!.value}\n"}},{"id":"max-instance-method","html_id":"max-instance-method","name":"max","doc":"Returns the largest key in the tree.","summary":"Returns the largest key in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"max","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root\nelse\n return nil\nend\nn = @root\nwhile n && n.right\n n = n.right\nend\nn.not_nil!.key\n"}},{"id":"merge(other:Enumerable(Tuple(L)),&block:K,V,W->V|W)forallL-instance-method","html_id":"merge(other:Enumerable(Tuple(L)),&block:K,V,W->V|W)forallL-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L))"}],"args_string":"(other : Enumerable(Tuple(L)), &block : K, V, W -> V | W) forall L","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L))"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V, W -> V | W)"},"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | L).new(self)\nstm.merge!(other) do |k, v1, v2|\n yield k, v1, v2\nend\nstm\n"}},{"id":"merge(other:Enumerable(L))forallL-instance-method","html_id":"merge(other:Enumerable(L))forallL-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(L)"}],"args_string":"(other : Enumerable(L)) forall L","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(L)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | L).new(self)\nstm.merge!(other)\nstm\n"}},{"id":"merge(other:Enumerable(A(Tuple(L,W))),&block:K,V,W->V|W)forallA,L,W-instance-method","html_id":"merge(other:Enumerable(A(Tuple(L,W))),&block:K,V,W->V|W)forallA,L,W-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"args_string":"(other : Enumerable(A(Tuple(L, W))), &block : K, V, W -> V | W) forall A, L, W","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V, W -> V | W)"},"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | W).new(self)\nstm.merge!(other) do |k, v1, v2|\n yield k, v1, v2\nend\nstm\n"}},{"id":"merge(other:Enumerable(A(Tuple(L,W))))forallA,L,W-instance-method","html_id":"merge(other:Enumerable(A(Tuple(L,W))))forallA,L,W-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"args_string":"(other : Enumerable(A(Tuple(L, W)))) forall A, L, W","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | W).new(self)\nstm.merge!(other)\nstm\n"}},{"id":"merge(other:Enumerable(Tuple(L,W)),&block:K,V,W->V|W)forallL,W-instance-method","html_id":"merge(other:Enumerable(Tuple(L,W)),&block:K,V,W->V|W)forallL,W-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L, W))"}],"args_string":"(other : Enumerable(Tuple(L, W)), &block : K, V, W -> V | W) forall L, W","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L, W))"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V, W -> V | W)"},"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | W).new(self)\nstm.merge!(other) do |k, v1, v2|\n yield k, v1, v2\nend\nstm\n"}},{"id":"merge(other:Enumerable(Tuple(L,W)))forallL,W-instance-method","html_id":"merge(other:Enumerable(Tuple(L,W)))forallL,W-instance-method","name":"merge","doc":"Returns a new `SplayTreeMap` with the keys and values of this tree and *other* combined.\nA value in *other* takes precedence over the one in this tree. Key types **must** be\ncomparable or this will cause a missing `no overload matches` exception on compilation.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.merge({\"baz\" => \"qux\"}) # => {\"foo\" => \"bar\", \"baz\" => \"qux\"}\nstm # => {\"foo\" => \"bar\"}\n```","summary":"Returns a new SplayTreeMap
with the keys and values of this tree and other combined.
Adds the contents of other to this SplayTreeMap
.
Returns the smallest key in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"min","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root\nelse\n return nil\nend\nn = @root\nwhile n && n.left\n n = n.left\nend\nn.not_nil!.key\n"}},{"id":"obtain(key:K):V-instance-method","html_id":"obtain(key:K):V-instance-method","name":"obtain","doc":"Obtain a key without splaying. This is much faster than using `#[]` but the\nlack of a splay operation means that the accessed value will not move closer\nto the root of the tree, which bypasses the normal optimization behavior of\nSplay Trees.\n\nA KeyError will be raised if the key can not be found in the tree.","summary":"Obtain a key without splaying.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"args_string":"(key : K) : V","source_link":null,"def":{"name":"obtain","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"V","visibility":"Public","body":"v = obtain_impl(key)\nv == Unk ? raise(KeyError.new(\"Missing hash key: #{key.inspect}\")) : v.as(V)\n"}},{"id":"prune-instance-method","html_id":"prune-instance-method","name":"prune","doc":"This will remove all of the leaves at the end of the tree branches.\nThat is, every node that does not have any children. This will tend\nto remove the least used elements from the tree.\nThis function is expensive, as implemented, as it must walk every\nnode in the tree.\nTODO: Come up with a more efficient way of getting this same effect.","summary":"This will remove all of the leaves at the end of the tree branches.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"prune","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root.nil?\n return\nend\nheight_limit = height / 2\ndescend_from(@root.not_nil!, height_limit)\nsplay(@root.not_nil!.key)\n"}},{"id":"put(key:K,value:V,&)-instance-method","html_id":"put(key:K,value:V,&)-instance-method","name":"put","doc":"Sets the value of *key* to the given *value*.\n\nIf a value already exists for `key`, that (old) value is returned.\nOtherwise the given block is invoked with *key* and its value is returned.\n\n```\nstm = SplayTreeMap(Int32, String).new\nstm.put(1, \"one\") { \"didn't exist\" } # => \"didn't exist\"\nstm.put(1, \"uno\") { \"didn't exist\" } # => \"one\"\nstm.put(2, \"two\") { |key| key.to_s } # => \"2\"\n```","summary":"Sets the value of key to the given value.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"V"}],"args_string":"(key : K, value : V, &)","source_link":null,"def":{"name":"put","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"V"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"old_value = push(key, value)\nold_value || (yield key)\n"}},{"id":"reject(*keys)-instance-method","html_id":"reject(*keys)-instance-method","name":"reject","doc":"Returns a new `SplayTreeMap` with the given keys removed.\n\n```\n{\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject(\"a\", \"c\") # => {\"b\" => 2, \"d\" => 4}\n```","summary":"Returns a new SplayTreeMap
with the given keys removed.
Removes a list of keys out of the tree, returning a new tree.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"args_string":"(keys : Array | Tuple)","source_link":null,"def":{"name":"reject","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = dup\nkeys.each do |k|\n stm.delete(k)\nend\nstm\n"}},{"id":"reject(&block:K,V->_)-instance-method","html_id":"reject(&block:K,V->_)-instance-method","name":"reject","doc":"Returns a new `SplayTreeMap` consisting of entries for which the block returns `false`.\n```\nstm = SplayTreeMap.new({\"a\" => 100, \"b\" => 200, \"c\" => 300})\nstm.reject { |k, v| k > \"a\" } # => {\"a\" => 100}\nstm.reject { |k, v| v < 200 } # => {\"b\" => 200, \"c\" => 300}\n```","summary":"Returns a new SplayTreeMap
consisting of entries for which the block returns false
.
Equivalent to SplayTreeMap#reject
, but modifies the current object rather than returning a new one.
Removes a list of keys out of the tree.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"args_string":"(keys : Array | Tuple)","source_link":null,"def":{"name":"reject!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"keys.each do |k|\n delete(k)\nend\nself\n"}},{"id":"reject!(*keys)-instance-method","html_id":"reject!(*keys)-instance-method","name":"reject!","doc":"Removes the given keys from the tree.\n\n```\n{\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject!(\"a\", \"c\") # => {\"b\" => 2, \"d\" => 4}\n```","summary":"Removes the given keys from the tree.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"args_string":"(*keys)","source_link":null,"def":{"name":"reject!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reject!(keys)"}},{"id":"root-instance-method","html_id":"root-instance-method","name":"root","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"root","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@root"}},{"id":"select(&block:K,V->_)-instance-method","html_id":"select(&block:K,V->_)-instance-method","name":"select","doc":"Returns a new hash consisting of entries for which the block returns `true`.\n```\nh = {\"a\" => 100, \"b\" => 200, \"c\" => 300}\nh.select { |k, v| k > \"a\" } # => {\"b\" => 200, \"c\" => 300}\nh.select { |k, v| v < 200 } # => {\"a\" => 100}\n```","summary":"Returns a new hash consisting of entries for which the block returns true
.
Returns a new SplayTreeMap
with the given keys.
Returns a new SplayTreeMap
with the given keys.
Removes every element except the given ones.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"args_string":"(*keys)","source_link":null,"def":{"name":"select!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"select!(keys)"}},{"id":"select!(&block:K,V->_)-instance-method","html_id":"select!(&block:K,V->_)-instance-method","name":"select!","doc":"Equivalent to `Hash#select` but makes modification on the current object rather that returning a new one. Returns `nil` if no changes were made","summary":"Equivalent to Hash#select
but makes modification on the current object rather that returning a new one.
Removes every element except the given ones.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"args_string":"(keys : Array | Tuple)","source_link":null,"def":{"name":"select!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |k, v|\n if keys.includes?(k)\n else\n delete(k)\n end\nend\nself\n"}},{"id":"size-instance-method","html_id":"size-instance-method","name":"size","doc":"Return the current number of key/value pairs in the tree.","summary":"Return the current number of key/value pairs in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"size","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@size"}},{"id":"to_a-instance-method","html_id":"to_a-instance-method","name":"to_a","doc":"Transform the `SplayTreeMap` into an `Array(Tuple(K, V))`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nary = stm.to_a # => [{\"baz\", \"qux\"}, {\"foo\", \"bar\"}]\nstm2 = SplayTreeMap.new(ary)\nstm == stm2 # => true\n```","summary":"Transform the SplayTreeMap
into an Array(Tuple(K, V))
.
Transform a SplayTreeMap(K,V)
into a Hash(K,V)
.
Transform the SplayTreeMap
into a String
representation.
Returns a new SplayTreeMap
with all of the key/value pairs converted using the provided block.
Returns a new SplayTreeMap
with all keys converted using the block operation.
Returns a new SplayTreeMap with all values converted using the block operation.
","abstract":false,"args":[],"args_string":"(&block : V -> V2) forall V2","source_link":null,"def":{"name":"transform_values","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(V -> V2)"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K, V2).new) do |__arg4, memo|\n key = __arg4[0]\n value = __arg4[1]\n memo[key] = yield value\nend"}},{"id":"transform_values!(&block:V->V)-instance-method","html_id":"transform_values!(&block:V->V)-instance-method","name":"transform_values!","doc":"Modifies the values of the current `SplayTreeMap` according to the provided block.\n\n```\nstm = SplayTreeMap.new({:a => 1, :b => 2, :c => 3})\nstm.transform_values! { |value| value + 1 } # => {:a => 2, :b => 3, :c => 4}\n```","summary":"Modifies the values of the current SplayTreeMap
according to the provided block.
Returns an array containing all of the values in the tree.
","abstract":false,"args":[],"args_string":" : Array(V)","source_link":null,"def":{"name":"values","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(V)","visibility":"Public","body":"a = [] of V\neach do |k, v|\n a << v\nend\na\n"}},{"id":"values_at(*indexes:K)-instance-method","html_id":"values_at(*indexes:K)-instance-method","name":"values_at","doc":"Returns a tuple populated with the values associated with the given *keys*.\nRaises a KeyError if any key is invalid.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4})\nstm.values_at(\"a\", \"c\") # => {1, 3}\nstm.values_at(\"a\", \"d\", \"e\") # => KeyError\n```","summary":"Returns a tuple populated with the values associated with the given keys.
","abstract":false,"args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"args_string":"(*indexes : K)","source_link":null,"def":{"name":"values_at","args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"indexes.map do |index|\n self[index]\nend"}},{"id":"values_at?(*indexes:K)-instance-method","html_id":"values_at?(*indexes:K)-instance-method","name":"values_at?","doc":"Returns a tuple populated with the values associated with the given *keys*.\nReturns `nil` for any key that is invalid.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4})\nstm.values_at?(\"a\", \"c\") # => {1, 3}\nstm.values_at?(\"a\", \"d\", \"e\") # => {1, 4, nil}\n```","summary":"Returns a tuple populated with the values associated with the given keys.
","abstract":false,"args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"args_string":"(*indexes : K)","source_link":null,"def":{"name":"values_at?","args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"indexes.map do |index|\n self[index]?\nend"}}],"macros":[],"types":[]},{"html_id":"Splay Tree Map/Stm","path":"Stm.html","kind":"module","full_name":"Stm","name":"Stm","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"Splay Tree Map","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.1.0\"","doc":null,"summary":null}],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"TODO: Write documentation for `Stm`","summary":"TODO Write documentation for Stm
Zips two arrays into a SplayTreeMap
, taking keys from ary1 and values from ary2.
Creates a new empty SplayTreeMap
with a block that is called when a key is missing from the tree.
Creates a new empty SplayTreeMap
with a block that is called when a key is missing from the tree.
Creates a new SplayTreeMap
, populating it with values from the Enumerable or the Iterable seed object, and with a default return value for any missing key.
Creates a new empty SplayTreeMap
with a default return value for any missing key.
Compares two SplayTreeMaps.
","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"SplayTreeMap(L, W)"}],"args_string":"(other : SplayTreeMap(L, W)) forall L, W","source_link":null,"def":{"name":"<=>","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"SplayTreeMap(L, W)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"cmp = surface_cmp(other)\nif cmp == 0\nelse\n return cmp\nend\nme_iter = each\nother_iter = other.each\ncmp = 0\nloop do\n me_entry = me_iter.next?\n other_entry = other_iter.next?\n if me_entry.nil? || other_entry.nil?\n return 0\n else\n cmp = (me_entry.as(::Tuple(K, V))) <=> (other_entry.as(::Tuple(L, W)))\n if cmp == 0\n else\n return cmp\n end\n end\nend\n"}},{"id":"[](key:K)-instance-method","html_id":"[](key:K)-instance-method","name":"[]","doc":"Searches for the given *key* in the tree and returns the associated value.\nIf the key is not in the tree, a KeyError will be raised.\n\n```\nstm = SplayTreeMap(String, String).new\nstm[\"foo\"] = \"bar\"\nstm[\"foo\"] # => \"bar\"\n\nstm = SplayTreeMap(String, String).new(\"bar\")\nstm[\"foo\"] # => \"bar\"\n\nstm = SplayTreeMap(String, String).new { \"bar\" }\nstm[\"foo\"] # => \"bar\"\n\nstm = Hash(String, String).new\nstm[\"foo\"] # raises KeyError\n```","summary":"Searches for the given key in the tree and returns the associated value.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"args_string":"(key : K)","source_link":null,"def":{"name":"[]","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(get(key)).as(V)"}},{"id":"[]=(key,value)-instance-method","html_id":"[]=(key,value)-instance-method","name":"[]=","doc":"Create a key/value association.\n\n```\nstm[\"this\"] = \"that\"\n```","summary":"Create a key/value association.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(key, value)","source_link":null,"def":{"name":"[]=","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"push(key, value)\nvalue\n"}},{"id":"[]?(key:K)-instance-method","html_id":"[]?(key:K)-instance-method","name":"[]?","doc":"Returns the value for the key given by *key*.\nIf not found, returns `nil`. This ignores the default value set by `Hash.new`.\n\n```\nstm = SplayTreeMap(String, String).new\nstm[\"foo\"]? # => \"bar\"\nstm[\"bar\"]? # => nil\n\nstm = SplayTreeMap(String, String).new(\"bar\")\nstm[\"foo\"]? # => nil\n```","summary":"Returns the value for the key given by key.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"args_string":"(key : K)","source_link":null,"def":{"name":"[]?","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"get(key: key, raise_exception: false)"}},{"id":"clear-instance-method","html_id":"clear-instance-method","name":"clear","doc":"Resets the state of the `SplayTreeMap`, clearing all key/value associations.","summary":"Resets the state of the SplayTreeMap
, clearing all key/value associations.
Returns new SplayTreeMap
that has all of the nil
values and their associated keys removed.
Removes all nil
values from self
.
Deletes the key-value pair and returns the value, else yields key with given block.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key, &)","source_link":null,"def":{"name":"delete","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"value = delete_impl(key)\nvalue != Unk ? value : yield key\n"}},{"id":"delete(key)-instance-method","html_id":"delete(key)-instance-method","name":"delete","doc":"Deletes the key-value pair and returns the value, otherwise returns `nil`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.delete(\"foo\") # => \"bar\"\nstm.fetch(\"foo\", nil) # => nil\n```","summary":"Deletes the key-value pair and returns the value, otherwise returns nil
.
DEPRECATED This is just #reject!
by another name.
Traverses the depth of a structure and returns the value, otherwise raises KeyError
.
Traverses the depth of a structure and returns the value.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"subkeys","doc":null,"default_value":"","external_name":"subkeys","restriction":""}],"args_string":"(key : K, *subkeys)","source_link":null,"def":{"name":"dig?","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"subkeys","doc":null,"default_value":"","external_name":"subkeys","restriction":""}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (value = self[key]?) && (value.responds_to?(:\"dig?\"))\n value.dig?(*subkeys)\nend"}},{"id":"dup-instance-method","html_id":"dup-instance-method","name":"dup","doc":"Duplicates a `SplayTreeMap`.\n\n```\nstm_a = {\"foo\" => \"bar\"}\nstm_b = hash_a.dup\nstm_b.merge!({\"baz\" => \"qux\"})\nstm_a # => {\"foo\" => \"bar\"}\n```","summary":"Duplicates a SplayTreeMap
.
Calls the given block for each key/value pair, passing the pair into the block.
","abstract":false,"args":[],"args_string":"(& : Tuple(K, V) -> ) : Nil","source_link":null,"def":{"name":"each","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"","doc":null,"default_value":"","external_name":"","restriction":"(::Tuple(K, V) -> )"},"return_type":"Nil","visibility":"Public","body":"iter = EntryIterator(K, V).new(self)\nwhile true\n entry = iter.next\n if entry == Iterator.stop\n break\n end\n yield entry.as(::Tuple(K, V))\nend\n"}},{"id":"each:EntryIterator(K,V)-instance-method","html_id":"each:EntryIterator(K,V)-instance-method","name":"each","doc":"Returns an iterator which can be used to access all of the elements in the tree.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"fob\" => \"baz\", \"qix\" => \"qux\"})\n\nset = [] of Tuple(String, String)\niterator = stm.each\nwhile entry = iterator.next\n set << entry\nend\n\nset # => [{\"fob\" => \"baz\"}, {\"foo\" => \"bar\", \"qix\" => \"qux\"}]\n","summary":"Returns an iterator which can be used to access all of the elements in the tree.
","abstract":false,"args":[],"args_string":" : EntryIterator(K, V)","source_link":null,"def":{"name":"each","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"EntryIterator(K, V)","visibility":"Public","body":"EntryIterator(K, V).new(self)"}},{"id":"each_key-instance-method","html_id":"each_key-instance-method","name":"each_key","doc":"Returns an iterator over the SplayTreeMap keys.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\niterator = stm.each_key\n\nkey = iterator.next\nkey # => \"foo\"\n\nkey = iterator.next\nkey # => \"baz\"\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Returns an iterator over the SplayTreeMap keys.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"each_key","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"KeyIterator(K, V).new(self)"}},{"id":"each_key(&)-instance-method","html_id":"each_key(&)-instance-method","name":"each_key","doc":"Calls the given block for each key-value pair and passes in the key.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.each_key do |key|\n key # => \"foo\"\nend\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Calls the given block for each key-value pair and passes in the key.
","abstract":false,"args":[],"args_string":"(&)","source_link":null,"def":{"name":"each_key","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |key, value|\n yield key\nend"}},{"id":"each_value-instance-method","html_id":"each_value-instance-method","name":"each_value","doc":"Returns an iterator over the hash values.\nWhich behaves like an `Iterator` consisting of the value's types.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\niterator = stm.each_value\n\nvalue = iterator.next\nvalue # => \"bar\"\n\nvalue = iterator.next\nvalue # => \"qux\"\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Returns an iterator over the hash values.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"each_value","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"ValueIterator(K, V).new(self)"}},{"id":"each_value(&)-instance-method","html_id":"each_value(&)-instance-method","name":"each_value","doc":"Calls the given block for each key-value pair and passes in the value.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.each_value do |value|\n value # => \"bar\"\nend\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Calls the given block for each key-value pair and passes in the value.
","abstract":false,"args":[],"args_string":"(&)","source_link":null,"def":{"name":"each_value","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |key, value|\n yield value\nend"}},{"id":"empty?-instance-method","html_id":"empty?-instance-method","name":"empty?","doc":"Returns true of the tree contains no key/value pairs.\n\n```\nstm = SplayTreeMap(Int32, Int32).new\nstm.empty? # => true\nstm[1] = 1\nstm.empty? # => false\n```\n","summary":"Returns true of the tree contains no key/value pairs.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"empty?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@size == 0"}},{"id":"fetch(key,&)-instance-method","html_id":"fetch(key,&)-instance-method","name":"fetch","doc":"Returns the value for the key given by *key*, or when not found calls the given block with the key.\nThis ignores the default value set by `SplayTreeMap.new`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.fetch(\"foo\") { \"default value\" } # => \"bar\"\nstm.fetch(\"bar\") { \"default value\" } # => \"default value\"\nstm.fetch(\"bar\") { |key| key.upcase } # => \"BAR\"\n```","summary":"Returns the value for the key given by key, or when not found calls the given block with the key.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key, &)","source_link":null,"def":{"name":"fetch","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"value = get_impl(key)\nvalue != Unk ? value : yield key\n"}},{"id":"fetch(key,default)-instance-method","html_id":"fetch(key,default)-instance-method","name":"fetch","doc":"Returns the value for the key given by *key*, or when not found the value given by *default*.\nThis ignores the default value set by `SplayTreeMap.new`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.fetch(\"foo\", \"foo\") # => \"bar\"\nstm.fetch(\"bar\", \"foo\") # => \"foo\"\n```","summary":"Returns the value for the key given by key, or when not found the value given by default.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"default","doc":null,"default_value":"","external_name":"default","restriction":""}],"args_string":"(key, default)","source_link":null,"def":{"name":"fetch","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"default","doc":null,"default_value":"","external_name":"default","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"fetch(key) do\n default\nend"}},{"id":"has_key?(key):Bool-instance-method","html_id":"has_key?(key):Bool-instance-method","name":"has_key?","doc":"Return a boolean value indicating whether the given key can be found in the tree.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2})\nstm.has_key?(\"a\") # => true\nstm.has_key?(\"c\") # => false\n```\n","summary":"Return a boolean value indicating whether the given key can be found in the tree.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key) : Bool","source_link":null,"def":{"name":"has_key?","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":"(get_impl(key)) == Unk ? false : true"}},{"id":"has_value?(value):Bool-instance-method","html_id":"has_value?(value):Bool-instance-method","name":"has_value?","doc":"Return a boolean value indicating whether the given value can be found in the tree.\nThis is potentially slow as it requires scanning the tree until a match is found or\nthe end of the tree is reached.\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2})\nstm.has_value?(\"2\") # => true\nstm.has_value?(\"4\") # => false\n```\n","summary":"Return a boolean value indicating whether the given value can be found in the tree.
","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value) : Bool","source_link":null,"def":{"name":"has_value?","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":"self.each do |k, v|\n if v == value\n return true\n end\nend\nfalse\n"}},{"id":"height-instance-method","html_id":"height-instance-method","name":"height","doc":"Return the height of the current tree.","summary":"Return the height of the current tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"height","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"height_recursive(@root)"}},{"id":"height(key):Int32?-instance-method","html_id":"height(key):Int32?-instance-method","name":"height","doc":"Return the height at which a given key can be found.","summary":"Return the height at which a given key can be found.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key) : Int32?","source_link":null,"def":{"name":"height","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32 | ::Nil","visibility":"Public","body":"node = @root\nif node.nil?\n return nil\nend\nh = 0\nloop do\n if node\n else\n return nil\n end\n cmp = key <=> node.key\n if cmp == -1\n h = h + 1\n node = node.left\n else\n if cmp == 1\n h = h + 1\n node = node.right\n else\n return h\n end\n end\nend\n"}},{"id":"key_for(value)-instance-method","html_id":"key_for(value)-instance-method","name":"key_for","doc":"Returns a key with the given *value*, else raises `KeyError`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nstm.key_for(\"bar\") # => \"foo\"\nstm.key_for(\"qux\") # => \"baz\"\nstm.key_for(\"foobar\") # raises KeyError\n```","summary":"Returns a key with the given value, else raises KeyError
.
Returns a key with the given value, else yields value with the given block.
","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value, &)","source_link":null,"def":{"name":"key_for","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |k, v|\n if v == value\n return k\n end\nend\nyield value\n"}},{"id":"key_for?(value)-instance-method","html_id":"key_for?(value)-instance-method","name":"key_for?","doc":"Returns a key with the given *value*, else `nil`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nstm.key_for?(\"bar\") # => \"foo\"\nstm.key_for?(\"qux\") # => \"baz\"\nstm.key_for?(\"foobar\") # => nil\n```","summary":"Returns a key with the given value, else nil
.
Returns an array of all keys in the tree.
","abstract":false,"args":[],"args_string":" : Array(K)","source_link":null,"def":{"name":"keys","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(K)","visibility":"Public","body":"a = [] of K\neach do |k, v|\n a << k\nend\na\n"}},{"id":"last-instance-method","html_id":"last-instance-method","name":"last","doc":"Returns the last key/value pair in the tree.","summary":"Returns the last key/value pair in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"last","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root\nelse\n return nil\nend\nn = @root\nwhile n && n.right\n n = n.right\nend\n{n.not_nil!.key, n.not_nil!.value}\n"}},{"id":"max-instance-method","html_id":"max-instance-method","name":"max","doc":"Returns the largest key in the tree.","summary":"Returns the largest key in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"max","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root\nelse\n return nil\nend\nn = @root\nwhile n && n.right\n n = n.right\nend\nn.not_nil!.key\n"}},{"id":"merge(other:Enumerable(Tuple(L)),&block:K,V,W->V|W)forallL-instance-method","html_id":"merge(other:Enumerable(Tuple(L)),&block:K,V,W->V|W)forallL-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L))"}],"args_string":"(other : Enumerable(Tuple(L)), &block : K, V, W -> V | W) forall L","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L))"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V, W -> V | W)"},"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | L).new(self)\nstm.merge!(other) do |k, v1, v2|\n yield k, v1, v2\nend\nstm\n"}},{"id":"merge(other:Enumerable(L))forallL-instance-method","html_id":"merge(other:Enumerable(L))forallL-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(L)"}],"args_string":"(other : Enumerable(L)) forall L","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(L)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | L).new(self)\nstm.merge!(other)\nstm\n"}},{"id":"merge(other:Enumerable(A(Tuple(L,W))),&block:K,V,W->V|W)forallA,L,W-instance-method","html_id":"merge(other:Enumerable(A(Tuple(L,W))),&block:K,V,W->V|W)forallA,L,W-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"args_string":"(other : Enumerable(A(Tuple(L, W))), &block : K, V, W -> V | W) forall A, L, W","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V, W -> V | W)"},"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | W).new(self)\nstm.merge!(other) do |k, v1, v2|\n yield k, v1, v2\nend\nstm\n"}},{"id":"merge(other:Enumerable(A(Tuple(L,W))))forallA,L,W-instance-method","html_id":"merge(other:Enumerable(A(Tuple(L,W))))forallA,L,W-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"args_string":"(other : Enumerable(A(Tuple(L, W)))) forall A, L, W","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | W).new(self)\nstm.merge!(other)\nstm\n"}},{"id":"merge(other:Enumerable(Tuple(L,W)),&block:K,V,W->V|W)forallL,W-instance-method","html_id":"merge(other:Enumerable(Tuple(L,W)),&block:K,V,W->V|W)forallL,W-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L, W))"}],"args_string":"(other : Enumerable(Tuple(L, W)), &block : K, V, W -> V | W) forall L, W","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L, W))"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V, W -> V | W)"},"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | W).new(self)\nstm.merge!(other) do |k, v1, v2|\n yield k, v1, v2\nend\nstm\n"}},{"id":"merge(other:Enumerable(Tuple(L,W)))forallL,W-instance-method","html_id":"merge(other:Enumerable(Tuple(L,W)))forallL,W-instance-method","name":"merge","doc":"Returns a new `SplayTreeMap` with the keys and values of this tree and *other* combined.\nA value in *other* takes precedence over the one in this tree. Key types **must** be\ncomparable or this will cause a missing `no overload matches` exception on compilation.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.merge({\"baz\" => \"qux\"}) # => {\"foo\" => \"bar\", \"baz\" => \"qux\"}\nstm # => {\"foo\" => \"bar\"}\n```","summary":"Returns a new SplayTreeMap
with the keys and values of this tree and other combined.
Adds the contents of other to this SplayTreeMap
.
Returns the smallest key in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"min","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root\nelse\n return nil\nend\nn = @root\nwhile n && n.left\n n = n.left\nend\nn.not_nil!.key\n"}},{"id":"obtain(key:K):V-instance-method","html_id":"obtain(key:K):V-instance-method","name":"obtain","doc":"Obtain a key without splaying. This is much faster than using `#[]` but the\nlack of a splay operation means that the accessed value will not move closer\nto the root of the tree, which bypasses the normal optimization behavior of\nSplay Trees.\n\nA KeyError will be raised if the key can not be found in the tree.","summary":"Obtain a key without splaying.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"args_string":"(key : K) : V","source_link":null,"def":{"name":"obtain","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"V","visibility":"Public","body":"v = obtain_impl(key)\nv == Unk ? raise(KeyError.new(\"Missing hash key: #{key.inspect}\")) : v.as(V)\n"}},{"id":"prune-instance-method","html_id":"prune-instance-method","name":"prune","doc":"This will remove all of the leaves at the end of the tree branches.\nThat is, every node that does not have any children. This will tend\nto remove the least used elements from the tree.\nThis function is expensive, as implemented, as it must walk every\nnode in the tree.\nTODO: Come up with a more efficient way of getting this same effect.","summary":"This will remove all of the leaves at the end of the tree branches.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"prune","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root.nil?\n return\nend\nheight_limit = height / 2\ndescend_from(@root.not_nil!, height_limit)\nsplay(@root.not_nil!.key)\n"}},{"id":"put(key:K,value:V,&)-instance-method","html_id":"put(key:K,value:V,&)-instance-method","name":"put","doc":"Sets the value of *key* to the given *value*.\n\nIf a value already exists for `key`, that (old) value is returned.\nOtherwise the given block is invoked with *key* and its value is returned.\n\n```\nstm = SplayTreeMap(Int32, String).new\nstm.put(1, \"one\") { \"didn't exist\" } # => \"didn't exist\"\nstm.put(1, \"uno\") { \"didn't exist\" } # => \"one\"\nstm.put(2, \"two\") { |key| key.to_s } # => \"2\"\n```","summary":"Sets the value of key to the given value.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"V"}],"args_string":"(key : K, value : V, &)","source_link":null,"def":{"name":"put","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"V"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"old_value = push(key, value)\nold_value || (yield key)\n"}},{"id":"reject(*keys)-instance-method","html_id":"reject(*keys)-instance-method","name":"reject","doc":"Returns a new `SplayTreeMap` with the given keys removed.\n\n```\n{\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject(\"a\", \"c\") # => {\"b\" => 2, \"d\" => 4}\n```","summary":"Returns a new SplayTreeMap
with the given keys removed.
Removes a list of keys out of the tree, returning a new tree.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"args_string":"(keys : Array | Tuple)","source_link":null,"def":{"name":"reject","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = dup\nkeys.each do |k|\n stm.delete(k)\nend\nstm\n"}},{"id":"reject(&block:K,V->_)-instance-method","html_id":"reject(&block:K,V->_)-instance-method","name":"reject","doc":"Returns a new `SplayTreeMap` consisting of entries for which the block returns `false`.\n```\nstm = SplayTreeMap.new({\"a\" => 100, \"b\" => 200, \"c\" => 300})\nstm.reject { |k, v| k > \"a\" } # => {\"a\" => 100}\nstm.reject { |k, v| v < 200 } # => {\"b\" => 200, \"c\" => 300}\n```","summary":"Returns a new SplayTreeMap
consisting of entries for which the block returns false
.
Equivalent to SplayTreeMap#reject
, but modifies the current object rather than returning a new one.
Removes a list of keys out of the tree.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"args_string":"(keys : Array | Tuple)","source_link":null,"def":{"name":"reject!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"keys.each do |k|\n delete(k)\nend\nself\n"}},{"id":"reject!(*keys)-instance-method","html_id":"reject!(*keys)-instance-method","name":"reject!","doc":"Removes the given keys from the tree.\n\n```\n{\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject!(\"a\", \"c\") # => {\"b\" => 2, \"d\" => 4}\n```","summary":"Removes the given keys from the tree.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"args_string":"(*keys)","source_link":null,"def":{"name":"reject!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reject!(keys)"}},{"id":"root-instance-method","html_id":"root-instance-method","name":"root","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"root","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@root"}},{"id":"select(&block:K,V->_)-instance-method","html_id":"select(&block:K,V->_)-instance-method","name":"select","doc":"Returns a new hash consisting of entries for which the block returns `true`.\n```\nh = {\"a\" => 100, \"b\" => 200, \"c\" => 300}\nh.select { |k, v| k > \"a\" } # => {\"b\" => 200, \"c\" => 300}\nh.select { |k, v| v < 200 } # => {\"a\" => 100}\n```","summary":"Returns a new hash consisting of entries for which the block returns true
.
Returns a new SplayTreeMap
with the given keys.
Returns a new SplayTreeMap
with the given keys.
Removes every element except the given ones.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"args_string":"(*keys)","source_link":null,"def":{"name":"select!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"select!(keys)"}},{"id":"select!(&block:K,V->_)-instance-method","html_id":"select!(&block:K,V->_)-instance-method","name":"select!","doc":"Equivalent to `Hash#select` but makes modification on the current object rather that returning a new one. Returns `nil` if no changes were made","summary":"Equivalent to Hash#select
but makes modification on the current object rather that returning a new one.
Removes every element except the given ones.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"args_string":"(keys : Array | Tuple)","source_link":null,"def":{"name":"select!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |k, v|\n if keys.includes?(k)\n else\n delete(k)\n end\nend\nself\n"}},{"id":"size-instance-method","html_id":"size-instance-method","name":"size","doc":"Return the current number of key/value pairs in the tree.","summary":"Return the current number of key/value pairs in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"size","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@size"}},{"id":"to_a-instance-method","html_id":"to_a-instance-method","name":"to_a","doc":"Transform the `SplayTreeMap` into an `Array(Tuple(K, V))`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nary = stm.to_a # => [{\"baz\", \"qux\"}, {\"foo\", \"bar\"}]\nstm2 = SplayTreeMap.new(ary)\nstm == stm2 # => true\n```","summary":"Transform the SplayTreeMap
into an Array(Tuple(K, V))
.
Transform a SplayTreeMap(K,V)
into a Hash(K,V)
.
Transform the SplayTreeMap
into a String
representation.
Returns a new SplayTreeMap
with all of the key/value pairs converted using the provided block.
Returns a new SplayTreeMap
with all keys converted using the block operation.
Returns a new SplayTreeMap with all values converted using the block operation.
","abstract":false,"args":[],"args_string":"(&block : V -> V2) forall V2","source_link":null,"def":{"name":"transform_values","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(V -> V2)"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K, V2).new) do |__arg4, memo|\n key = __arg4[0]\n value = __arg4[1]\n memo[key] = yield value\nend"}},{"id":"transform_values!(&block:V->V)-instance-method","html_id":"transform_values!(&block:V->V)-instance-method","name":"transform_values!","doc":"Modifies the values of the current `SplayTreeMap` according to the provided block.\n\n```\nstm = SplayTreeMap.new({:a => 1, :b => 2, :c => 3})\nstm.transform_values! { |value| value + 1 } # => {:a => 2, :b => 3, :c => 4}\n```","summary":"Modifies the values of the current SplayTreeMap
according to the provided block.
Returns an array containing all of the values in the tree.
","abstract":false,"args":[],"args_string":" : Array(V)","source_link":null,"def":{"name":"values","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(V)","visibility":"Public","body":"a = [] of V\neach do |k, v|\n a << v\nend\na\n"}},{"id":"values_at(*indexes:K)-instance-method","html_id":"values_at(*indexes:K)-instance-method","name":"values_at","doc":"Returns a tuple populated with the values associated with the given *keys*.\nRaises a KeyError if any key is invalid.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4})\nstm.values_at(\"a\", \"c\") # => {1, 3}\nstm.values_at(\"a\", \"d\", \"e\") # => KeyError\n```","summary":"Returns a tuple populated with the values associated with the given keys.
","abstract":false,"args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"args_string":"(*indexes : K)","source_link":null,"def":{"name":"values_at","args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"indexes.map do |index|\n self[index]\nend"}},{"id":"values_at?(*indexes:K)-instance-method","html_id":"values_at?(*indexes:K)-instance-method","name":"values_at?","doc":"Returns a tuple populated with the values associated with the given *keys*.\nReturns `nil` for any key that is invalid.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4})\nstm.values_at?(\"a\", \"c\") # => {1, 3}\nstm.values_at?(\"a\", \"d\", \"e\") # => {1, 4, nil}\n```","summary":"Returns a tuple populated with the values associated with the given keys.
","abstract":false,"args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"args_string":"(*indexes : K)","source_link":null,"def":{"name":"values_at?","args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"indexes.map do |index|\n self[index]?\nend"}}],"macros":[],"types":[]},{"html_id":"Splay Tree Map/Stm","path":"Stm.html","kind":"module","full_name":"Stm","name":"Stm","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"Splay Tree Map","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.1.0\"","doc":null,"summary":null}],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"TODO: Write documentation for `Stm`","summary":"TODO Write documentation for Stm
Zips two arrays into a SplayTreeMap
, taking keys from ary1 and values from ary2.
Creates a new empty SplayTreeMap
with a block that is called when a key is missing from the tree.
Creates a new empty SplayTreeMap
with a block that is called when a key is missing from the tree.
Creates a new SplayTreeMap
, populating it with values from the Enumerable or the Iterable seed object, and with a default return value for any missing key.
Creates a new empty SplayTreeMap
with a default return value for any missing key.
Compares two SplayTreeMaps.
","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"SplayTreeMap(L, W)"}],"args_string":"(other : SplayTreeMap(L, W)) forall L, W","source_link":null,"def":{"name":"<=>","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"SplayTreeMap(L, W)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"cmp = surface_cmp(other)\nif cmp == 0\nelse\n return cmp\nend\nme_iter = each\nother_iter = other.each\ncmp = 0\nloop do\n me_entry = me_iter.next?\n other_entry = other_iter.next?\n if me_entry.nil? || other_entry.nil?\n return 0\n else\n cmp = (me_entry.as(::Tuple(K, V))) <=> (other_entry.as(::Tuple(L, W)))\n if cmp == 0\n else\n return cmp\n end\n end\nend\n"}},{"id":"[](key:K)-instance-method","html_id":"[](key:K)-instance-method","name":"[]","doc":"Searches for the given *key* in the tree and returns the associated value.\nIf the key is not in the tree, a KeyError will be raised.\n\n```\nstm = SplayTreeMap(String, String).new\nstm[\"foo\"] = \"bar\"\nstm[\"foo\"] # => \"bar\"\n\nstm = SplayTreeMap(String, String).new(\"bar\")\nstm[\"foo\"] # => \"bar\"\n\nstm = SplayTreeMap(String, String).new { \"bar\" }\nstm[\"foo\"] # => \"bar\"\n\nstm = Hash(String, String).new\nstm[\"foo\"] # raises KeyError\n```","summary":"Searches for the given key in the tree and returns the associated value.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"args_string":"(key : K)","source_link":null,"def":{"name":"[]","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(get(key)).as(V)"}},{"id":"[]=(key,value)-instance-method","html_id":"[]=(key,value)-instance-method","name":"[]=","doc":"Create a key/value association.\n\n```\nstm[\"this\"] = \"that\"\n```","summary":"Create a key/value association.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(key, value)","source_link":null,"def":{"name":"[]=","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"push(key, value)\nvalue\n"}},{"id":"[]?(key:K)-instance-method","html_id":"[]?(key:K)-instance-method","name":"[]?","doc":"Returns the value for the key given by *key*.\nIf not found, returns `nil`. This ignores the default value set by `Hash.new`.\n\n```\nstm = SplayTreeMap(String, String).new\nstm[\"foo\"]? # => \"bar\"\nstm[\"bar\"]? # => nil\n\nstm = SplayTreeMap(String, String).new(\"bar\")\nstm[\"foo\"]? # => nil\n```","summary":"Returns the value for the key given by key.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"args_string":"(key : K)","source_link":null,"def":{"name":"[]?","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"get(key: key, raise_exception: false)"}},{"id":"clear-instance-method","html_id":"clear-instance-method","name":"clear","doc":"Resets the state of the `SplayTreeMap`, clearing all key/value associations.","summary":"Resets the state of the SplayTreeMap
, clearing all key/value associations.
Returns new SplayTreeMap
that has all of the nil
values and their associated keys removed.
Removes all nil
values from self
.
Deletes the key-value pair and returns the value, else yields key with given block.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key, &)","source_link":null,"def":{"name":"delete","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"value = delete_impl(key)\nvalue != Unk ? value : yield key\n"}},{"id":"delete(key)-instance-method","html_id":"delete(key)-instance-method","name":"delete","doc":"Deletes the key-value pair and returns the value, otherwise returns `nil`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.delete(\"foo\") # => \"bar\"\nstm.fetch(\"foo\", nil) # => nil\n```","summary":"Deletes the key-value pair and returns the value, otherwise returns nil
.
DEPRECATED This is just #reject!
by another name.
Traverses the depth of a structure and returns the value, otherwise raises KeyError
.
Traverses the depth of a structure and returns the value.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"subkeys","doc":null,"default_value":"","external_name":"subkeys","restriction":""}],"args_string":"(key : K, *subkeys)","source_link":null,"def":{"name":"dig?","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"subkeys","doc":null,"default_value":"","external_name":"subkeys","restriction":""}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (value = self[key]?) && (value.responds_to?(:\"dig?\"))\n value.dig?(*subkeys)\nend"}},{"id":"dup-instance-method","html_id":"dup-instance-method","name":"dup","doc":"Duplicates a `SplayTreeMap`.\n\n```\nstm_a = {\"foo\" => \"bar\"}\nstm_b = hash_a.dup\nstm_b.merge!({\"baz\" => \"qux\"})\nstm_a # => {\"foo\" => \"bar\"}\n```","summary":"Duplicates a SplayTreeMap
.
Calls the given block for each key/value pair, passing the pair into the block.
","abstract":false,"args":[],"args_string":"(& : Tuple(K, V) -> ) : Nil","source_link":null,"def":{"name":"each","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"","doc":null,"default_value":"","external_name":"","restriction":"(::Tuple(K, V) -> )"},"return_type":"Nil","visibility":"Public","body":"iter = EntryIterator(K, V).new(self)\nwhile true\n entry = iter.next\n if entry == Iterator.stop\n break\n end\n yield entry.as(::Tuple(K, V))\nend\n"}},{"id":"each:EntryIterator(K,V)-instance-method","html_id":"each:EntryIterator(K,V)-instance-method","name":"each","doc":"Returns an iterator which can be used to access all of the elements in the tree.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"fob\" => \"baz\", \"qix\" => \"qux\"})\n\nset = [] of Tuple(String, String)\niterator = stm.each\nwhile entry = iterator.next\n set << entry\nend\n\nset # => [{\"fob\" => \"baz\"}, {\"foo\" => \"bar\", \"qix\" => \"qux\"}]\n","summary":"Returns an iterator which can be used to access all of the elements in the tree.
","abstract":false,"args":[],"args_string":" : EntryIterator(K, V)","source_link":null,"def":{"name":"each","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"EntryIterator(K, V)","visibility":"Public","body":"EntryIterator(K, V).new(self)"}},{"id":"each_key-instance-method","html_id":"each_key-instance-method","name":"each_key","doc":"Returns an iterator over the SplayTreeMap keys.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\niterator = stm.each_key\n\nkey = iterator.next\nkey # => \"foo\"\n\nkey = iterator.next\nkey # => \"baz\"\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Returns an iterator over the SplayTreeMap keys.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"each_key","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"KeyIterator(K, V).new(self)"}},{"id":"each_key(&)-instance-method","html_id":"each_key(&)-instance-method","name":"each_key","doc":"Calls the given block for each key-value pair and passes in the key.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.each_key do |key|\n key # => \"foo\"\nend\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Calls the given block for each key-value pair and passes in the key.
","abstract":false,"args":[],"args_string":"(&)","source_link":null,"def":{"name":"each_key","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |key, value|\n yield key\nend"}},{"id":"each_value-instance-method","html_id":"each_value-instance-method","name":"each_value","doc":"Returns an iterator over the hash values.\nWhich behaves like an `Iterator` consisting of the value's types.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\niterator = stm.each_value\n\nvalue = iterator.next\nvalue # => \"bar\"\n\nvalue = iterator.next\nvalue # => \"qux\"\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Returns an iterator over the hash values.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"each_value","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"ValueIterator(K, V).new(self)"}},{"id":"each_value(&)-instance-method","html_id":"each_value(&)-instance-method","name":"each_value","doc":"Calls the given block for each key-value pair and passes in the value.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.each_value do |value|\n value # => \"bar\"\nend\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Calls the given block for each key-value pair and passes in the value.
","abstract":false,"args":[],"args_string":"(&)","source_link":null,"def":{"name":"each_value","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |key, value|\n yield value\nend"}},{"id":"empty?-instance-method","html_id":"empty?-instance-method","name":"empty?","doc":"Returns true of the tree contains no key/value pairs.\n\n```\nstm = SplayTreeMap(Int32, Int32).new\nstm.empty? # => true\nstm[1] = 1\nstm.empty? # => false\n```\n","summary":"Returns true of the tree contains no key/value pairs.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"empty?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@size == 0"}},{"id":"fetch(key,&)-instance-method","html_id":"fetch(key,&)-instance-method","name":"fetch","doc":"Returns the value for the key given by *key*, or when not found calls the given block with the key.\nThis ignores the default value set by `SplayTreeMap.new`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.fetch(\"foo\") { \"default value\" } # => \"bar\"\nstm.fetch(\"bar\") { \"default value\" } # => \"default value\"\nstm.fetch(\"bar\") { |key| key.upcase } # => \"BAR\"\n```","summary":"Returns the value for the key given by key, or when not found calls the given block with the key.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key, &)","source_link":null,"def":{"name":"fetch","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"value = get_impl(key)\nvalue != Unk ? value : yield key\n"}},{"id":"fetch(key,default)-instance-method","html_id":"fetch(key,default)-instance-method","name":"fetch","doc":"Returns the value for the key given by *key*, or when not found the value given by *default*.\nThis ignores the default value set by `SplayTreeMap.new`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.fetch(\"foo\", \"foo\") # => \"bar\"\nstm.fetch(\"bar\", \"foo\") # => \"foo\"\n```","summary":"Returns the value for the key given by key, or when not found the value given by default.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"default","doc":null,"default_value":"","external_name":"default","restriction":""}],"args_string":"(key, default)","source_link":null,"def":{"name":"fetch","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"default","doc":null,"default_value":"","external_name":"default","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"fetch(key) do\n default\nend"}},{"id":"has_key?(key):Bool-instance-method","html_id":"has_key?(key):Bool-instance-method","name":"has_key?","doc":"Return a boolean value indicating whether the given key can be found in the tree.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2})\nstm.has_key?(\"a\") # => true\nstm.has_key?(\"c\") # => false\n```\n","summary":"Return a boolean value indicating whether the given key can be found in the tree.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key) : Bool","source_link":null,"def":{"name":"has_key?","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":"(get_impl(key)) == Unk ? false : true"}},{"id":"has_value?(value):Bool-instance-method","html_id":"has_value?(value):Bool-instance-method","name":"has_value?","doc":"Return a boolean value indicating whether the given value can be found in the tree.\nThis is potentially slow as it requires scanning the tree until a match is found or\nthe end of the tree is reached.\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2})\nstm.has_value?(\"2\") # => true\nstm.has_value?(\"4\") # => false\n```\n","summary":"Return a boolean value indicating whether the given value can be found in the tree.
","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value) : Bool","source_link":null,"def":{"name":"has_value?","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":"self.each do |k, v|\n if v == value\n return true\n end\nend\nfalse\n"}},{"id":"height-instance-method","html_id":"height-instance-method","name":"height","doc":"Return the height of the current tree.","summary":"Return the height of the current tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"height","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"height_recursive(@root)"}},{"id":"height(key):Int32?-instance-method","html_id":"height(key):Int32?-instance-method","name":"height","doc":"Return the height at which a given key can be found.","summary":"Return the height at which a given key can be found.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key) : Int32?","source_link":null,"def":{"name":"height","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32 | ::Nil","visibility":"Public","body":"node = @root\nif node.nil?\n return nil\nend\nh = 0\nloop do\n if node\n else\n return nil\n end\n cmp = key <=> node.key\n if cmp == -1\n h = h + 1\n node = node.left\n else\n if cmp == 1\n h = h + 1\n node = node.right\n else\n return h\n end\n end\nend\n"}},{"id":"key_for(value)-instance-method","html_id":"key_for(value)-instance-method","name":"key_for","doc":"Returns a key with the given *value*, else raises `KeyError`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nstm.key_for(\"bar\") # => \"foo\"\nstm.key_for(\"qux\") # => \"baz\"\nstm.key_for(\"foobar\") # raises KeyError\n```","summary":"Returns a key with the given value, else raises KeyError
.
Returns a key with the given value, else yields value with the given block.
","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value, &)","source_link":null,"def":{"name":"key_for","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |k, v|\n if v == value\n return k\n end\nend\nyield value\n"}},{"id":"key_for?(value)-instance-method","html_id":"key_for?(value)-instance-method","name":"key_for?","doc":"Returns a key with the given *value*, else `nil`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nstm.key_for?(\"bar\") # => \"foo\"\nstm.key_for?(\"qux\") # => \"baz\"\nstm.key_for?(\"foobar\") # => nil\n```","summary":"Returns a key with the given value, else nil
.
Returns an array of all keys in the tree.
","abstract":false,"args":[],"args_string":" : Array(K)","source_link":null,"def":{"name":"keys","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(K)","visibility":"Public","body":"a = [] of K\neach do |k, v|\n a << k\nend\na\n"}},{"id":"last-instance-method","html_id":"last-instance-method","name":"last","doc":"Returns the last key/value pair in the tree.","summary":"Returns the last key/value pair in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"last","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root\nelse\n return nil\nend\nn = @root\nwhile n && n.right\n n = n.right\nend\n{n.not_nil!.key, n.not_nil!.value}\n"}},{"id":"max-instance-method","html_id":"max-instance-method","name":"max","doc":"Returns the largest key in the tree.","summary":"Returns the largest key in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"max","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root\nelse\n return nil\nend\nn = @root\nwhile n && n.right\n n = n.right\nend\nn.not_nil!.key\n"}},{"id":"merge(other:Enumerable(Tuple(L)),&block:K,V,W->V|W)forallL-instance-method","html_id":"merge(other:Enumerable(Tuple(L)),&block:K,V,W->V|W)forallL-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L))"}],"args_string":"(other : Enumerable(Tuple(L)), &block : K, V, W -> V | W) forall L","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L))"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V, W -> V | W)"},"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | L).new(self)\nstm.merge!(other) do |k, v1, v2|\n yield k, v1, v2\nend\nstm\n"}},{"id":"merge(other:Enumerable(L))forallL-instance-method","html_id":"merge(other:Enumerable(L))forallL-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(L)"}],"args_string":"(other : Enumerable(L)) forall L","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(L)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | L).new(self)\nstm.merge!(other)\nstm\n"}},{"id":"merge(other:Enumerable(A(Tuple(L,W))),&block:K,V,W->V|W)forallA,L,W-instance-method","html_id":"merge(other:Enumerable(A(Tuple(L,W))),&block:K,V,W->V|W)forallA,L,W-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"args_string":"(other : Enumerable(A(Tuple(L, W))), &block : K, V, W -> V | W) forall A, L, W","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V, W -> V | W)"},"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | W).new(self)\nstm.merge!(other) do |k, v1, v2|\n yield k, v1, v2\nend\nstm\n"}},{"id":"merge(other:Enumerable(A(Tuple(L,W))))forallA,L,W-instance-method","html_id":"merge(other:Enumerable(A(Tuple(L,W))))forallA,L,W-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"args_string":"(other : Enumerable(A(Tuple(L, W)))) forall A, L, W","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | W).new(self)\nstm.merge!(other)\nstm\n"}},{"id":"merge(other:Enumerable(Tuple(L,W)),&block:K,V,W->V|W)forallL,W-instance-method","html_id":"merge(other:Enumerable(Tuple(L,W)),&block:K,V,W->V|W)forallL,W-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L, W))"}],"args_string":"(other : Enumerable(Tuple(L, W)), &block : K, V, W -> V | W) forall L, W","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L, W))"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V, W -> V | W)"},"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | W).new(self)\nstm.merge!(other) do |k, v1, v2|\n yield k, v1, v2\nend\nstm\n"}},{"id":"merge(other:Enumerable(Tuple(L,W)))forallL,W-instance-method","html_id":"merge(other:Enumerable(Tuple(L,W)))forallL,W-instance-method","name":"merge","doc":"Returns a new `SplayTreeMap` with the keys and values of this tree and *other* combined.\nA value in *other* takes precedence over the one in this tree. Key types **must** be\ncomparable or this will cause a missing `no overload matches` exception on compilation.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.merge({\"baz\" => \"qux\"}) # => {\"foo\" => \"bar\", \"baz\" => \"qux\"}\nstm # => {\"foo\" => \"bar\"}\n```","summary":"Returns a new SplayTreeMap
with the keys and values of this tree and other combined.
Adds the contents of other to this SplayTreeMap
.
Returns the smallest key in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"min","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root\nelse\n return nil\nend\nn = @root\nwhile n && n.left\n n = n.left\nend\nn.not_nil!.key\n"}},{"id":"obtain(key:K):V-instance-method","html_id":"obtain(key:K):V-instance-method","name":"obtain","doc":"Obtain a key without splaying. This is much faster than using `#[]` but the\nlack of a splay operation means that the accessed value will not move closer\nto the root of the tree, which bypasses the normal optimization behavior of\nSplay Trees.\n\nA KeyError will be raised if the key can not be found in the tree.","summary":"Obtain a key without splaying.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"args_string":"(key : K) : V","source_link":null,"def":{"name":"obtain","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"V","visibility":"Public","body":"v = obtain_impl(key)\nv == Unk ? raise(KeyError.new(\"Missing hash key: #{key.inspect}\")) : v.as(V)\n"}},{"id":"prune-instance-method","html_id":"prune-instance-method","name":"prune","doc":"This will remove all of the leaves at the end of the tree branches.\nThat is, every node that does not have any children. This will tend\nto remove the least used elements from the tree.\nThis function is expensive, as implemented, as it must walk every\nnode in the tree.\nTODO: Come up with a more efficient way of getting this same effect.","summary":"This will remove all of the leaves at the end of the tree branches.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"prune","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root.nil?\n return\nend\nheight_limit = height / 2\ndescend_from(@root.not_nil!, height_limit)\nsplay(@root.not_nil!.key)\n"}},{"id":"put(key:K,value:V,&)-instance-method","html_id":"put(key:K,value:V,&)-instance-method","name":"put","doc":"Sets the value of *key* to the given *value*.\n\nIf a value already exists for `key`, that (old) value is returned.\nOtherwise the given block is invoked with *key* and its value is returned.\n\n```\nstm = SplayTreeMap(Int32, String).new\nstm.put(1, \"one\") { \"didn't exist\" } # => \"didn't exist\"\nstm.put(1, \"uno\") { \"didn't exist\" } # => \"one\"\nstm.put(2, \"two\") { |key| key.to_s } # => \"2\"\n```","summary":"Sets the value of key to the given value.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"V"}],"args_string":"(key : K, value : V, &)","source_link":null,"def":{"name":"put","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"V"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"old_value = push(key, value)\nold_value || (yield key)\n"}},{"id":"reject(*keys)-instance-method","html_id":"reject(*keys)-instance-method","name":"reject","doc":"Returns a new `SplayTreeMap` with the given keys removed.\n\n```\n{\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject(\"a\", \"c\") # => {\"b\" => 2, \"d\" => 4}\n```","summary":"Returns a new SplayTreeMap
with the given keys removed.
Removes a list of keys out of the tree, returning a new tree.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"args_string":"(keys : Array | Tuple)","source_link":null,"def":{"name":"reject","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = dup\nkeys.each do |k|\n stm.delete(k)\nend\nstm\n"}},{"id":"reject(&block:K,V->_)-instance-method","html_id":"reject(&block:K,V->_)-instance-method","name":"reject","doc":"Returns a new `SplayTreeMap` consisting of entries for which the block returns `false`.\n```\nstm = SplayTreeMap.new({\"a\" => 100, \"b\" => 200, \"c\" => 300})\nstm.reject { |k, v| k > \"a\" } # => {\"a\" => 100}\nstm.reject { |k, v| v < 200 } # => {\"b\" => 200, \"c\" => 300}\n```","summary":"Returns a new SplayTreeMap
consisting of entries for which the block returns false
.
Equivalent to SplayTreeMap#reject
, but modifies the current object rather than returning a new one.
Removes a list of keys out of the tree.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"args_string":"(keys : Array | Tuple)","source_link":null,"def":{"name":"reject!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"keys.each do |k|\n delete(k)\nend\nself\n"}},{"id":"reject!(*keys)-instance-method","html_id":"reject!(*keys)-instance-method","name":"reject!","doc":"Removes the given keys from the tree.\n\n```\n{\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject!(\"a\", \"c\") # => {\"b\" => 2, \"d\" => 4}\n```","summary":"Removes the given keys from the tree.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"args_string":"(*keys)","source_link":null,"def":{"name":"reject!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reject!(keys)"}},{"id":"root-instance-method","html_id":"root-instance-method","name":"root","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"root","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@root"}},{"id":"select(&block:K,V->_)-instance-method","html_id":"select(&block:K,V->_)-instance-method","name":"select","doc":"Returns a new hash consisting of entries for which the block returns `true`.\n```\nh = {\"a\" => 100, \"b\" => 200, \"c\" => 300}\nh.select { |k, v| k > \"a\" } # => {\"b\" => 200, \"c\" => 300}\nh.select { |k, v| v < 200 } # => {\"a\" => 100}\n```","summary":"Returns a new hash consisting of entries for which the block returns true
.
Returns a new SplayTreeMap
with the given keys.
Returns a new SplayTreeMap
with the given keys.
Removes every element except the given ones.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"args_string":"(*keys)","source_link":null,"def":{"name":"select!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"select!(keys)"}},{"id":"select!(&block:K,V->_)-instance-method","html_id":"select!(&block:K,V->_)-instance-method","name":"select!","doc":"Equivalent to `Hash#select` but makes modification on the current object rather that returning a new one. Returns `nil` if no changes were made","summary":"Equivalent to Hash#select
but makes modification on the current object rather that returning a new one.
Removes every element except the given ones.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"args_string":"(keys : Array | Tuple)","source_link":null,"def":{"name":"select!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |k, v|\n if keys.includes?(k)\n else\n delete(k)\n end\nend\nself\n"}},{"id":"size-instance-method","html_id":"size-instance-method","name":"size","doc":"Return the current number of key/value pairs in the tree.","summary":"Return the current number of key/value pairs in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"size","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@size"}},{"id":"to_a-instance-method","html_id":"to_a-instance-method","name":"to_a","doc":"Transform the `SplayTreeMap` into an `Array(Tuple(K, V))`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nary = stm.to_a # => [{\"baz\", \"qux\"}, {\"foo\", \"bar\"}]\nstm2 = SplayTreeMap.new(ary)\nstm == stm2 # => true\n```","summary":"Transform the SplayTreeMap
into an Array(Tuple(K, V))
.
Transform a SplayTreeMap(K,V)
into a Hash(K,V)
.
Transform the SplayTreeMap
into a String
representation.
Returns a new SplayTreeMap
with all of the key/value pairs converted using the provided block.
Returns a new SplayTreeMap
with all keys converted using the block operation.
Returns a new SplayTreeMap with all values converted using the block operation.
","abstract":false,"args":[],"args_string":"(&block : V -> V2) forall V2","source_link":null,"def":{"name":"transform_values","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(V -> V2)"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K, V2).new) do |__arg4, memo|\n key = __arg4[0]\n value = __arg4[1]\n memo[key] = yield value\nend"}},{"id":"transform_values!(&block:V->V)-instance-method","html_id":"transform_values!(&block:V->V)-instance-method","name":"transform_values!","doc":"Modifies the values of the current `SplayTreeMap` according to the provided block.\n\n```\nstm = SplayTreeMap.new({:a => 1, :b => 2, :c => 3})\nstm.transform_values! { |value| value + 1 } # => {:a => 2, :b => 3, :c => 4}\n```","summary":"Modifies the values of the current SplayTreeMap
according to the provided block.
Returns an array containing all of the values in the tree.
","abstract":false,"args":[],"args_string":" : Array(V)","source_link":null,"def":{"name":"values","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(V)","visibility":"Public","body":"a = [] of V\neach do |k, v|\n a << v\nend\na\n"}},{"id":"values_at(*indexes:K)-instance-method","html_id":"values_at(*indexes:K)-instance-method","name":"values_at","doc":"Returns a tuple populated with the values associated with the given *keys*.\nRaises a KeyError if any key is invalid.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4})\nstm.values_at(\"a\", \"c\") # => {1, 3}\nstm.values_at(\"a\", \"d\", \"e\") # => KeyError\n```","summary":"Returns a tuple populated with the values associated with the given keys.
","abstract":false,"args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"args_string":"(*indexes : K)","source_link":null,"def":{"name":"values_at","args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"indexes.map do |index|\n self[index]\nend"}},{"id":"values_at?(*indexes:K)-instance-method","html_id":"values_at?(*indexes:K)-instance-method","name":"values_at?","doc":"Returns a tuple populated with the values associated with the given *keys*.\nReturns `nil` for any key that is invalid.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4})\nstm.values_at?(\"a\", \"c\") # => {1, 3}\nstm.values_at?(\"a\", \"d\", \"e\") # => {1, 4, nil}\n```","summary":"Returns a tuple populated with the values associated with the given keys.
","abstract":false,"args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"args_string":"(*indexes : K)","source_link":null,"def":{"name":"values_at?","args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"indexes.map do |index|\n self[index]?\nend"}}],"macros":[],"types":[]},{"html_id":"Splay Tree Map/Stm","path":"Stm.html","kind":"module","full_name":"Stm","name":"Stm","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"Splay Tree Map","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.1.0\"","doc":null,"summary":null}],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"TODO: Write documentation for `Stm`","summary":"TODO Write documentation for Stm
Zips two arrays into a SplayTreeMap
, taking keys from ary1 and values from ary2.
Creates a new empty SplayTreeMap
with a block that is called when a key is missing from the tree.
Creates a new empty SplayTreeMap
with a block that is called when a key is missing from the tree.
Creates a new SplayTreeMap
, populating it with values from the Enumerable or the Iterable seed object, and with a default return value for any missing key.
Creates a new empty SplayTreeMap
with a default return value for any missing key.
Compares two SplayTreeMaps.
","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"SplayTreeMap(L, W)"}],"args_string":"(other : SplayTreeMap(L, W)) forall L, W","source_link":null,"def":{"name":"<=>","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"SplayTreeMap(L, W)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"cmp = surface_cmp(other)\nif cmp == 0\nelse\n return cmp\nend\nme_iter = each\nother_iter = other.each\ncmp = 0\nloop do\n me_entry = me_iter.next?\n other_entry = other_iter.next?\n if me_entry.nil? || other_entry.nil?\n return 0\n else\n cmp = (me_entry.as(::Tuple(K, V))) <=> (other_entry.as(::Tuple(L, W)))\n if cmp == 0\n else\n return cmp\n end\n end\nend\n"}},{"id":"[](key:K)-instance-method","html_id":"[](key:K)-instance-method","name":"[]","doc":"Searches for the given *key* in the tree and returns the associated value.\nIf the key is not in the tree, a KeyError will be raised.\n\n```\nstm = SplayTreeMap(String, String).new\nstm[\"foo\"] = \"bar\"\nstm[\"foo\"] # => \"bar\"\n\nstm = SplayTreeMap(String, String).new(\"bar\")\nstm[\"foo\"] # => \"bar\"\n\nstm = SplayTreeMap(String, String).new { \"bar\" }\nstm[\"foo\"] # => \"bar\"\n\nstm = Hash(String, String).new\nstm[\"foo\"] # raises KeyError\n```","summary":"Searches for the given key in the tree and returns the associated value.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"args_string":"(key : K)","source_link":null,"def":{"name":"[]","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(get(key)).as(V)"}},{"id":"[]=(key,value)-instance-method","html_id":"[]=(key,value)-instance-method","name":"[]=","doc":"Create a key/value association.\n\n```\nstm[\"this\"] = \"that\"\n```","summary":"Create a key/value association.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(key, value)","source_link":null,"def":{"name":"[]=","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"push(key, value)\nvalue\n"}},{"id":"[]?(key:K)-instance-method","html_id":"[]?(key:K)-instance-method","name":"[]?","doc":"Returns the value for the key given by *key*.\nIf not found, returns `nil`. This ignores the default value set by `Hash.new`.\n\n```\nstm = SplayTreeMap(String, String).new\nstm[\"foo\"]? # => \"bar\"\nstm[\"bar\"]? # => nil\n\nstm = SplayTreeMap(String, String).new(\"bar\")\nstm[\"foo\"]? # => nil\n```","summary":"Returns the value for the key given by key.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"args_string":"(key : K)","source_link":null,"def":{"name":"[]?","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"get(key: key, raise_exception: false)"}},{"id":"clear-instance-method","html_id":"clear-instance-method","name":"clear","doc":"Resets the state of the `SplayTreeMap`, clearing all key/value associations.","summary":"Resets the state of the SplayTreeMap
, clearing all key/value associations.
Returns new SplayTreeMap
that has all of the nil
values and their associated keys removed.
Removes all nil
values from self
.
Deletes the key-value pair and returns the value, else yields key with given block.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key, &)","source_link":null,"def":{"name":"delete","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"value = delete_impl(key)\nvalue != Unk ? value : yield key\n"}},{"id":"delete(key)-instance-method","html_id":"delete(key)-instance-method","name":"delete","doc":"Deletes the key-value pair and returns the value, otherwise returns `nil`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.delete(\"foo\") # => \"bar\"\nstm.fetch(\"foo\", nil) # => nil\n```","summary":"Deletes the key-value pair and returns the value, otherwise returns nil
.
DEPRECATED This is just #reject!
by another name.
Traverses the depth of a structure and returns the value, otherwise raises KeyError
.
Traverses the depth of a structure and returns the value.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"subkeys","doc":null,"default_value":"","external_name":"subkeys","restriction":""}],"args_string":"(key : K, *subkeys)","source_link":null,"def":{"name":"dig?","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"subkeys","doc":null,"default_value":"","external_name":"subkeys","restriction":""}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (value = self[key]?) && (value.responds_to?(:\"dig?\"))\n value.dig?(*subkeys)\nend"}},{"id":"dup-instance-method","html_id":"dup-instance-method","name":"dup","doc":"Duplicates a `SplayTreeMap`.\n\n```\nstm_a = {\"foo\" => \"bar\"}\nstm_b = hash_a.dup\nstm_b.merge!({\"baz\" => \"qux\"})\nstm_a # => {\"foo\" => \"bar\"}\n```","summary":"Duplicates a SplayTreeMap
.
Calls the given block for each key/value pair, passing the pair into the block.
","abstract":false,"args":[],"args_string":"(& : Tuple(K, V) -> ) : Nil","source_link":null,"def":{"name":"each","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"","doc":null,"default_value":"","external_name":"","restriction":"(::Tuple(K, V) -> )"},"return_type":"Nil","visibility":"Public","body":"iter = EntryIterator(K, V).new(self)\nwhile true\n entry = iter.next\n if entry == Iterator.stop\n break\n end\n yield entry.as(::Tuple(K, V))\nend\n"}},{"id":"each:EntryIterator(K,V)-instance-method","html_id":"each:EntryIterator(K,V)-instance-method","name":"each","doc":"Returns an iterator which can be used to access all of the elements in the tree.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"fob\" => \"baz\", \"qix\" => \"qux\"})\n\nset = [] of Tuple(String, String)\niterator = stm.each\nwhile entry = iterator.next\n set << entry\nend\n\nset # => [{\"fob\" => \"baz\"}, {\"foo\" => \"bar\", \"qix\" => \"qux\"}]\n","summary":"Returns an iterator which can be used to access all of the elements in the tree.
","abstract":false,"args":[],"args_string":" : EntryIterator(K, V)","source_link":null,"def":{"name":"each","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"EntryIterator(K, V)","visibility":"Public","body":"EntryIterator(K, V).new(self)"}},{"id":"each_key-instance-method","html_id":"each_key-instance-method","name":"each_key","doc":"Returns an iterator over the SplayTreeMap keys.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\niterator = stm.each_key\n\nkey = iterator.next\nkey # => \"foo\"\n\nkey = iterator.next\nkey # => \"baz\"\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Returns an iterator over the SplayTreeMap keys.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"each_key","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"KeyIterator(K, V).new(self)"}},{"id":"each_key(&)-instance-method","html_id":"each_key(&)-instance-method","name":"each_key","doc":"Calls the given block for each key-value pair and passes in the key.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.each_key do |key|\n key # => \"foo\"\nend\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Calls the given block for each key-value pair and passes in the key.
","abstract":false,"args":[],"args_string":"(&)","source_link":null,"def":{"name":"each_key","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |key, value|\n yield key\nend"}},{"id":"each_value-instance-method","html_id":"each_value-instance-method","name":"each_value","doc":"Returns an iterator over the hash values.\nWhich behaves like an `Iterator` consisting of the value's types.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\niterator = stm.each_value\n\nvalue = iterator.next\nvalue # => \"bar\"\n\nvalue = iterator.next\nvalue # => \"qux\"\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Returns an iterator over the hash values.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"each_value","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"ValueIterator(K, V).new(self)"}},{"id":"each_value(&)-instance-method","html_id":"each_value(&)-instance-method","name":"each_value","doc":"Calls the given block for each key-value pair and passes in the value.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.each_value do |value|\n value # => \"bar\"\nend\n```\n\nThe enumeration is in tree order, from smallest to largest.","summary":"Calls the given block for each key-value pair and passes in the value.
","abstract":false,"args":[],"args_string":"(&)","source_link":null,"def":{"name":"each_value","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |key, value|\n yield value\nend"}},{"id":"empty?-instance-method","html_id":"empty?-instance-method","name":"empty?","doc":"Returns true of the tree contains no key/value pairs.\n\n```\nstm = SplayTreeMap(Int32, Int32).new\nstm.empty? # => true\nstm[1] = 1\nstm.empty? # => false\n```\n","summary":"Returns true of the tree contains no key/value pairs.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"empty?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@size == 0"}},{"id":"fetch(key,&)-instance-method","html_id":"fetch(key,&)-instance-method","name":"fetch","doc":"Returns the value for the key given by *key*, or when not found calls the given block with the key.\nThis ignores the default value set by `SplayTreeMap.new`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.fetch(\"foo\") { \"default value\" } # => \"bar\"\nstm.fetch(\"bar\") { \"default value\" } # => \"default value\"\nstm.fetch(\"bar\") { |key| key.upcase } # => \"BAR\"\n```","summary":"Returns the value for the key given by key, or when not found calls the given block with the key.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key, &)","source_link":null,"def":{"name":"fetch","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"value = get_impl(key)\nvalue != Unk ? value : yield key\n"}},{"id":"fetch(key,default)-instance-method","html_id":"fetch(key,default)-instance-method","name":"fetch","doc":"Returns the value for the key given by *key*, or when not found the value given by *default*.\nThis ignores the default value set by `SplayTreeMap.new`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.fetch(\"foo\", \"foo\") # => \"bar\"\nstm.fetch(\"bar\", \"foo\") # => \"foo\"\n```","summary":"Returns the value for the key given by key, or when not found the value given by default.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"default","doc":null,"default_value":"","external_name":"default","restriction":""}],"args_string":"(key, default)","source_link":null,"def":{"name":"fetch","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""},{"name":"default","doc":null,"default_value":"","external_name":"default","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"fetch(key) do\n default\nend"}},{"id":"has_key?(key):Bool-instance-method","html_id":"has_key?(key):Bool-instance-method","name":"has_key?","doc":"Return a boolean value indicating whether the given key can be found in the tree.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2})\nstm.has_key?(\"a\") # => true\nstm.has_key?(\"c\") # => false\n```\n","summary":"Return a boolean value indicating whether the given key can be found in the tree.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key) : Bool","source_link":null,"def":{"name":"has_key?","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":"(get_impl(key)) == Unk ? false : true"}},{"id":"has_value?(value):Bool-instance-method","html_id":"has_value?(value):Bool-instance-method","name":"has_value?","doc":"Return a boolean value indicating whether the given value can be found in the tree.\nThis is potentially slow as it requires scanning the tree until a match is found or\nthe end of the tree is reached.\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2})\nstm.has_value?(\"2\") # => true\nstm.has_value?(\"4\") # => false\n```\n","summary":"Return a boolean value indicating whether the given value can be found in the tree.
","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value) : Bool","source_link":null,"def":{"name":"has_value?","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":"self.each do |k, v|\n if v == value\n return true\n end\nend\nfalse\n"}},{"id":"height-instance-method","html_id":"height-instance-method","name":"height","doc":"Return the height of the current tree.","summary":"Return the height of the current tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"height","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"height_recursive(@root)"}},{"id":"height(key):Int32?-instance-method","html_id":"height(key):Int32?-instance-method","name":"height","doc":"Return the height at which a given key can be found.","summary":"Return the height at which a given key can be found.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"args_string":"(key) : Int32?","source_link":null,"def":{"name":"height","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32 | ::Nil","visibility":"Public","body":"node = @root\nif node.nil?\n return nil\nend\nh = 0\nloop do\n if node\n else\n return nil\n end\n cmp = key <=> node.key\n if cmp == -1\n h = h + 1\n node = node.left\n else\n if cmp == 1\n h = h + 1\n node = node.right\n else\n return h\n end\n end\nend\n"}},{"id":"key_for(value)-instance-method","html_id":"key_for(value)-instance-method","name":"key_for","doc":"Returns a key with the given *value*, else raises `KeyError`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nstm.key_for(\"bar\") # => \"foo\"\nstm.key_for(\"qux\") # => \"baz\"\nstm.key_for(\"foobar\") # raises KeyError\n```","summary":"Returns a key with the given value, else raises KeyError
.
Returns a key with the given value, else yields value with the given block.
","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value, &)","source_link":null,"def":{"name":"key_for","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |k, v|\n if v == value\n return k\n end\nend\nyield value\n"}},{"id":"key_for?(value)-instance-method","html_id":"key_for?(value)-instance-method","name":"key_for?","doc":"Returns a key with the given *value*, else `nil`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nstm.key_for?(\"bar\") # => \"foo\"\nstm.key_for?(\"qux\") # => \"baz\"\nstm.key_for?(\"foobar\") # => nil\n```","summary":"Returns a key with the given value, else nil
.
Returns an array of all keys in the tree.
","abstract":false,"args":[],"args_string":" : Array(K)","source_link":null,"def":{"name":"keys","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(K)","visibility":"Public","body":"a = [] of K\neach do |k, v|\n a << k\nend\na\n"}},{"id":"last-instance-method","html_id":"last-instance-method","name":"last","doc":"Returns the last key/value pair in the tree.","summary":"Returns the last key/value pair in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"last","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root\nelse\n return nil\nend\nn = @root\nwhile n && n.right\n n = n.right\nend\n{n.not_nil!.key, n.not_nil!.value}\n"}},{"id":"max-instance-method","html_id":"max-instance-method","name":"max","doc":"Returns the largest key in the tree.","summary":"Returns the largest key in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"max","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root\nelse\n return nil\nend\nn = @root\nwhile n && n.right\n n = n.right\nend\nn.not_nil!.key\n"}},{"id":"merge(other:Enumerable(Tuple(L)),&block:K,V,W->V|W)forallL-instance-method","html_id":"merge(other:Enumerable(Tuple(L)),&block:K,V,W->V|W)forallL-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L))"}],"args_string":"(other : Enumerable(Tuple(L)), &block : K, V, W -> V | W) forall L","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L))"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V, W -> V | W)"},"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | L).new(self)\nstm.merge!(other) do |k, v1, v2|\n yield k, v1, v2\nend\nstm\n"}},{"id":"merge(other:Enumerable(L))forallL-instance-method","html_id":"merge(other:Enumerable(L))forallL-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(L)"}],"args_string":"(other : Enumerable(L)) forall L","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(L)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | L).new(self)\nstm.merge!(other)\nstm\n"}},{"id":"merge(other:Enumerable(A(Tuple(L,W))),&block:K,V,W->V|W)forallA,L,W-instance-method","html_id":"merge(other:Enumerable(A(Tuple(L,W))),&block:K,V,W->V|W)forallA,L,W-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"args_string":"(other : Enumerable(A(Tuple(L, W))), &block : K, V, W -> V | W) forall A, L, W","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V, W -> V | W)"},"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | W).new(self)\nstm.merge!(other) do |k, v1, v2|\n yield k, v1, v2\nend\nstm\n"}},{"id":"merge(other:Enumerable(A(Tuple(L,W))))forallA,L,W-instance-method","html_id":"merge(other:Enumerable(A(Tuple(L,W))))forallA,L,W-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"args_string":"(other : Enumerable(A(Tuple(L, W)))) forall A, L, W","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(A(::Tuple(L, W)))"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | W).new(self)\nstm.merge!(other)\nstm\n"}},{"id":"merge(other:Enumerable(Tuple(L,W)),&block:K,V,W->V|W)forallL,W-instance-method","html_id":"merge(other:Enumerable(Tuple(L,W)),&block:K,V,W->V|W)forallL,W-instance-method","name":"merge","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L, W))"}],"args_string":"(other : Enumerable(Tuple(L, W)), &block : K, V, W -> V | W) forall L, W","source_link":null,"def":{"name":"merge","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L, W))"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V, W -> V | W)"},"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K | L, V | W).new(self)\nstm.merge!(other) do |k, v1, v2|\n yield k, v1, v2\nend\nstm\n"}},{"id":"merge(other:Enumerable(Tuple(L,W)))forallL,W-instance-method","html_id":"merge(other:Enumerable(Tuple(L,W)))forallL,W-instance-method","name":"merge","doc":"Returns a new `SplayTreeMap` with the keys and values of this tree and *other* combined.\nA value in *other* takes precedence over the one in this tree. Key types **must** be\ncomparable or this will cause a missing `no overload matches` exception on compilation.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.merge({\"baz\" => \"qux\"}) # => {\"foo\" => \"bar\", \"baz\" => \"qux\"}\nstm # => {\"foo\" => \"bar\"}\n```","summary":"Returns a new SplayTreeMap
with the keys and values of this tree and other combined.
Adds the contents of other to this SplayTreeMap
.
Returns the smallest key in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"min","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root\nelse\n return nil\nend\nn = @root\nwhile n && n.left\n n = n.left\nend\nn.not_nil!.key\n"}},{"id":"obtain(key:K):V-instance-method","html_id":"obtain(key:K):V-instance-method","name":"obtain","doc":"Obtain a key without splaying. This is much faster than using `#[]` but the\nlack of a splay operation means that the accessed value will not move closer\nto the root of the tree, which bypasses the normal optimization behavior of\nSplay Trees.\n\nA KeyError will be raised if the key can not be found in the tree.","summary":"Obtain a key without splaying.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"args_string":"(key : K) : V","source_link":null,"def":{"name":"obtain","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"V","visibility":"Public","body":"v = obtain_impl(key)\nv == Unk ? raise(KeyError.new(\"Missing hash key: #{key.inspect}\")) : v.as(V)\n"}},{"id":"prune-instance-method","html_id":"prune-instance-method","name":"prune","doc":"This will remove all of the leaves at the end of the tree branches.\nThat is, every node that does not have any children. This will tend\nto remove the least used elements from the tree.\nThis function is expensive, as implemented, as it must walk every\nnode in the tree.\nTODO: Come up with a more efficient way of getting this same effect.","summary":"This will remove all of the leaves at the end of the tree branches.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"prune","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @root.nil?\n return\nend\nheight_limit = height / 2\ndescend_from(@root.not_nil!, height_limit)\nsplay(@root.not_nil!.key)\n"}},{"id":"put(key:K,value:V,&)-instance-method","html_id":"put(key:K,value:V,&)-instance-method","name":"put","doc":"Sets the value of *key* to the given *value*.\n\nIf a value already exists for `key`, that (old) value is returned.\nOtherwise the given block is invoked with *key* and its value is returned.\n\n```\nstm = SplayTreeMap(Int32, String).new\nstm.put(1, \"one\") { \"didn't exist\" } # => \"didn't exist\"\nstm.put(1, \"uno\") { \"didn't exist\" } # => \"one\"\nstm.put(2, \"two\") { |key| key.to_s } # => \"2\"\n```","summary":"Sets the value of key to the given value.
","abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"V"}],"args_string":"(key : K, value : V, &)","source_link":null,"def":{"name":"put","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"K"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"V"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"old_value = push(key, value)\nold_value || (yield key)\n"}},{"id":"reject(*keys)-instance-method","html_id":"reject(*keys)-instance-method","name":"reject","doc":"Returns a new `SplayTreeMap` with the given keys removed.\n\n```\n{\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject(\"a\", \"c\") # => {\"b\" => 2, \"d\" => 4}\n```","summary":"Returns a new SplayTreeMap
with the given keys removed.
Removes a list of keys out of the tree, returning a new tree.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"args_string":"(keys : Array | Tuple)","source_link":null,"def":{"name":"reject","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = dup\nkeys.each do |k|\n stm.delete(k)\nend\nstm\n"}},{"id":"reject(&block:K,V->_)-instance-method","html_id":"reject(&block:K,V->_)-instance-method","name":"reject","doc":"Returns a new `SplayTreeMap` consisting of entries for which the block returns `false`.\n```\nstm = SplayTreeMap.new({\"a\" => 100, \"b\" => 200, \"c\" => 300})\nstm.reject { |k, v| k > \"a\" } # => {\"a\" => 100}\nstm.reject { |k, v| v < 200 } # => {\"b\" => 200, \"c\" => 300}\n```","summary":"Returns a new SplayTreeMap
consisting of entries for which the block returns false
.
Equivalent to SplayTreeMap#reject
, but modifies the current object rather than returning a new one.
Removes a list of keys out of the tree.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"args_string":"(keys : Array | Tuple)","source_link":null,"def":{"name":"reject!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"keys.each do |k|\n delete(k)\nend\nself\n"}},{"id":"reject!(*keys)-instance-method","html_id":"reject!(*keys)-instance-method","name":"reject!","doc":"Removes the given keys from the tree.\n\n```\n{\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject!(\"a\", \"c\") # => {\"b\" => 2, \"d\" => 4}\n```","summary":"Removes the given keys from the tree.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"args_string":"(*keys)","source_link":null,"def":{"name":"reject!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reject!(keys)"}},{"id":"root-instance-method","html_id":"root-instance-method","name":"root","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"root","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@root"}},{"id":"select(&block:K,V->_)-instance-method","html_id":"select(&block:K,V->_)-instance-method","name":"select","doc":"Returns a new hash consisting of entries for which the block returns `true`.\n```\nh = {\"a\" => 100, \"b\" => 200, \"c\" => 300}\nh.select { |k, v| k > \"a\" } # => {\"b\" => 200, \"c\" => 300}\nh.select { |k, v| v < 200 } # => {\"a\" => 100}\n```","summary":"Returns a new hash consisting of entries for which the block returns true
.
Returns a new SplayTreeMap
with the given keys.
Returns a new SplayTreeMap
with the given keys.
Removes every element except the given ones.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"args_string":"(*keys)","source_link":null,"def":{"name":"select!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"select!(keys)"}},{"id":"select!(&block:K,V->_)-instance-method","html_id":"select!(&block:K,V->_)-instance-method","name":"select!","doc":"Equivalent to `Hash#select` but makes modification on the current object rather that returning a new one. Returns `nil` if no changes were made","summary":"Equivalent to Hash#select
but makes modification on the current object rather that returning a new one.
Removes every element except the given ones.
","abstract":false,"args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"args_string":"(keys : Array | Tuple)","source_link":null,"def":{"name":"select!","args":[{"name":"keys","doc":null,"default_value":"","external_name":"keys","restriction":"Array | Tuple"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |k, v|\n if keys.includes?(k)\n else\n delete(k)\n end\nend\nself\n"}},{"id":"size-instance-method","html_id":"size-instance-method","name":"size","doc":"Return the current number of key/value pairs in the tree.","summary":"Return the current number of key/value pairs in the tree.
","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"size","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@size"}},{"id":"to_a-instance-method","html_id":"to_a-instance-method","name":"to_a","doc":"Transform the `SplayTreeMap` into an `Array(Tuple(K, V))`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nary = stm.to_a # => [{\"baz\", \"qux\"}, {\"foo\", \"bar\"}]\nstm2 = SplayTreeMap.new(ary)\nstm == stm2 # => true\n```","summary":"Transform the SplayTreeMap
into an Array(Tuple(K, V))
.
Transform a SplayTreeMap(K,V)
into a Hash(K,V)
.
Transform the SplayTreeMap
into a String
representation.
Returns a new SplayTreeMap
with all of the key/value pairs converted using the provided block.
Returns a new SplayTreeMap
with all keys converted using the block operation.
Returns a new SplayTreeMap with all values converted using the block operation.
","abstract":false,"args":[],"args_string":"(&block : V -> V2) forall V2","source_link":null,"def":{"name":"transform_values","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(V -> V2)"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K, V2).new) do |__arg4, memo|\n key = __arg4[0]\n value = __arg4[1]\n memo[key] = yield value\nend"}},{"id":"transform_values!(&block:V->V)-instance-method","html_id":"transform_values!(&block:V->V)-instance-method","name":"transform_values!","doc":"Modifies the values of the current `SplayTreeMap` according to the provided block.\n\n```\nstm = SplayTreeMap.new({:a => 1, :b => 2, :c => 3})\nstm.transform_values! { |value| value + 1 } # => {:a => 2, :b => 3, :c => 4}\n```","summary":"Modifies the values of the current SplayTreeMap
according to the provided block.
Returns an array containing all of the values in the tree.
","abstract":false,"args":[],"args_string":" : Array(V)","source_link":null,"def":{"name":"values","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(V)","visibility":"Public","body":"a = [] of V\neach do |k, v|\n a << v\nend\na\n"}},{"id":"values_at(*indexes:K)-instance-method","html_id":"values_at(*indexes:K)-instance-method","name":"values_at","doc":"Returns a tuple populated with the values associated with the given *keys*.\nRaises a KeyError if any key is invalid.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4})\nstm.values_at(\"a\", \"c\") # => {1, 3}\nstm.values_at(\"a\", \"d\", \"e\") # => KeyError\n```","summary":"Returns a tuple populated with the values associated with the given keys.
","abstract":false,"args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"args_string":"(*indexes : K)","source_link":null,"def":{"name":"values_at","args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"indexes.map do |index|\n self[index]\nend"}},{"id":"values_at?(*indexes:K)-instance-method","html_id":"values_at?(*indexes:K)-instance-method","name":"values_at?","doc":"Returns a tuple populated with the values associated with the given *keys*.\nReturns `nil` for any key that is invalid.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4})\nstm.values_at?(\"a\", \"c\") # => {1, 3}\nstm.values_at?(\"a\", \"d\", \"e\") # => {1, 4, nil}\n```","summary":"Returns a tuple populated with the values associated with the given keys.
","abstract":false,"args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"args_string":"(*indexes : K)","source_link":null,"def":{"name":"values_at?","args":[{"name":"indexes","doc":null,"default_value":"","external_name":"indexes","restriction":"K"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"indexes.map do |index|\n self[index]?\nend"}}],"macros":[],"types":[]},{"html_id":"Splay Tree Map/Stm","path":"Stm.html","kind":"module","full_name":"Stm","name":"Stm","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"Splay Tree Map","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"\"0.1.0\"","doc":null,"summary":null}],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"TODO: Write documentation for `Stm`","summary":"TODO Write documentation for Stm