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 @@

Splay Tree Map

+

GitHub release

+

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 @@

accessed elements towards the root of the tree, the least frequently accessed items tend to migrate towards the leaves of the tree. This implementation offers a method that can be used to prune its leaves, which generally has the -effect of removing the least frequently accessed items from the hash.

+effect of removing the least frequently accessed items from the tree.

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 @@

Usage

-

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 @@

stm.delete("junk") -puts stm.find("something") # This finds, but doesn't splay. +puts stm.obtain("something") # This finds, but doesn't splay. stm.prune # remove all leaves diff --git a/docs/index.json b/docs/index.json index 91bc221..d36ec04 100644 --- a/docs/index.json +++ b/docs/index.json @@ -1 +1 @@ -{"repository_name":"Splay Tree Map","body":"# Splay Tree Map\n\nA splay tree is a type of binary search tree that self organizes so that the\nmost frequently accessed items tend to be towards the root of the tree, where\nthey can be accessed more quickly.\n\nThis implementation provides a hash-like interface, and it provides a couple\nfeatures not typically found in Splay Trees -- efficient removal of the items\nthat are generally least frequently accessed, and an extra fast search option.\n\n### Leaf Pruning\n\nBecause splay trees tend to organize themselves with the most frequently\naccessed elements towards the root of the tree, the least frequently accessed\nitems tend to migrate towards the leaves of the tree. This implementation\noffers a method that can be used to prune its leaves, which generally has the\neffect of removing the least frequently accessed items from the hash.\n\nThis is useful if the data structure is being used to implement a cache, as\nit can be used to control the size of the cache while generaly keeping the\nmost useful items in the cache without any other extensive bookkeeping.\n\n### Search without Splaying\n\nA splay operation is generally performed on any access to a splay tree. This is\nthe operation that moves the most important items towards the root. This operation\nhas a cost to it, however, and there are times when it is desireable to search the\nhash without a splay operation occuring for the key that is searched. This results\nin a faster search operation, at the cost of not performing any efficiency improving\nstructural changes to the tree. This should not be the primary search method that\nis used, but it can be useful at the right time.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n stm:\n github: wyhaines/splay_tree_map.cr\n ```\n\n2. Run `shards install`\n\n## Usage\n\nFull documentation can be found at: https://wyhaines.github.io/splay_tree_map.cr/index.html\n\n```crystal\nrequire \"splay_tree_map\"\n```\n\nGenerally, the data structure is used like a hash.\n\n```crystal\nstm = SplayTreeMap(String, String).new\n\nstm[\"this\"] = \"that\"\nstm[\"something\"] = \"else\"\nstm[\"junk\"] = \"pile\"\n\nif stm.has_key?(\"this\")\n puts stm[\"this\"]\nend\n\nstm.delete(\"junk\")\n\nputs stm.find(\"something\") # This finds, but doesn't splay.\n\nstm.prune # remove all leaves\n```\n\n## TODO\n\nExperiment with other variations of splay operations, such as lazy semi-splay\nto see if performance can be improved. Right now this isn't any better than\njust using a Hash and arbitrarily deleting half of the hash if it grows too big.\n\n## Credits\n\nThis implementation is derived from the incomplete and broken implementation\nin the Crystalline shard found at https://github.com/jtomschroeder/crystalline\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Kirk Haines](https://github.com/wyhaines) - creator and maintainer\n","program":{"html_id":"Splay Tree Map/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"Splay Tree Map","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"Splay Tree Map/SplayTreeMap","path":"SplayTreeMap.html","kind":"class","full_name":"SplayTreeMap(K, V)","name":"SplayTreeMap","abstract":false,"superclass":{"html_id":"Splay Tree Map/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Splay Tree Map/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Splay Tree Map/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"Splay Tree Map/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"Splay Tree Map/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Splay Tree Map/Object","kind":"class","full_name":"Object","name":"Object"}],"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":[{"html_id":"Splay Tree Map/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Splay Tree Map/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"Splay Tree Map/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[{"id":"zip(ary1:Array(K),ary2:Array(V))-class-method","html_id":"zip(ary1:Array(K),ary2:Array(V))-class-method","name":"zip","doc":"Zips two arrays into a `SplayTreeMap`, taking keys from *ary1* and values from *ary2*.\n\n```\nSplayTreeMap.zip([\"key1\", \"key2\", \"key3\"], [\"value1\", \"value2\", \"value3\"])\n# => {\"key1\" => \"value1\", \"key2\" => \"value2\", \"key3\" => \"value3\"}\n```","summary":"

Zips two arrays into a SplayTreeMap, taking keys from ary1 and values from ary2.

","abstract":false,"args":[{"name":"ary1","doc":null,"default_value":"","external_name":"ary1","restriction":"Array(K)"},{"name":"ary2","doc":null,"default_value":"","external_name":"ary2","restriction":"Array(V)"}],"args_string":"(ary1 : Array(K), ary2 : Array(V))","source_link":null,"def":{"name":"zip","args":[{"name":"ary1","doc":null,"default_value":"","external_name":"ary1","restriction":"Array(K)"},{"name":"ary2","doc":null,"default_value":"","external_name":"ary2","restriction":"Array(V)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K, V).new\nary1.each_with_index do |key, i|\n stm[key] = ary2[i]\nend\nstm\n"}}],"constructors":[{"id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,block:SplayTreeMap(K,V),K->V?=nil)-class-method","html_id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,block:SplayTreeMap(K,V),K->V?=nil)-class-method","name":"new","doc":"Creates a new empty `SplayTreeMap` with a *block* that is called when a key is\nmissing from the tree.\n\n```\nstm = SplayTreeMap(String, Array(Int32)).new { |t, k| t[k] = [] of Int32 }\nstm[\"a\"] << 1\nstm[\"a\"] << 2\nstm[\"a\"] << 3\nputs stm.inspect # => [1,2,3]\n```","summary":"

Creates a new empty SplayTreeMap with a block that is called when a key is missing from the tree.

","abstract":false,"args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"block","doc":null,"default_value":"nil","external_name":"block","restriction":"(SplayTreeMap(K, V), K -> V) | ::Nil"}],"args_string":"(seed : Enumerable(Tuple(K, V))? | Iterable(Tuple(K, V))? = nil, block : SplayTreeMap(K, V), K -> V? = nil)","source_link":null,"def":{"name":"new","args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"block","doc":null,"default_value":"nil","external_name":"block","restriction":"(SplayTreeMap(K, V), K -> V) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = SplayTreeMap(K, V).allocate\n_.initialize(seed, block)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,&block:SplayTreeMap(K,V),K->V)-class-method","html_id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,&block:SplayTreeMap(K,V),K->V)-class-method","name":"new","doc":"Creates a new empty `SplayTreeMap` with a *block* that is called when a key is\nmissing from the tree.\n\n```\nstm = SplayTreeMap(String, Array(Int32)).new { |t, k| t[k] = [] of Int32 }\nstm[\"a\"] << 1\nstm[\"a\"] << 2\nstm[\"a\"] << 3\nputs stm.inspect # => [1,2,3]\n```","summary":"

Creates a new empty SplayTreeMap with a block that is called when a key is missing from the tree.

","abstract":false,"args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"}],"args_string":"(seed : Enumerable(Tuple(K, V))? | Iterable(Tuple(K, V))? = nil, &block : SplayTreeMap(K, V), K -> V)","source_link":null,"def":{"name":"new","args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(SplayTreeMap(K, V), K -> V)"},"return_type":"","visibility":"Public","body":"new(seed: seed, block: block)"}},{"id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?,default_value:V)-class-method","html_id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?,default_value:V)-class-method","name":"new","doc":"Creates a new `SplayTreeMap`, populating it with values from the *Enumerable*\nor the *Iterable* seed object, and with a default return value for any missing\nkey.\n\n```\nstm = SplayTreeMap.new({\"this\" => \"that\", \"something\" => \"else\"}, \"Unknown\")\nstm[\"something\"] # => \"else\"\nstm[\"xyzzy\"] # => \"Unknown\"\n```","summary":"

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.

","abstract":false,"args":[{"name":"seed","doc":null,"default_value":"","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"args_string":"(seed : Enumerable(Tuple(K, V))? | Iterable(Tuple(K, V))?, default_value : V)","source_link":null,"def":{"name":"new","args":[{"name":"seed","doc":null,"default_value":"","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new(seed: seed) do\n default_value\nend"}},{"id":"new(default_value:V)-class-method","html_id":"new(default_value:V)-class-method","name":"new","doc":"Creates a new empty `SplayTreeMap` with a default return value for any missing key.\n\n```\nstm = SplayTreeMap(String, String).new(\"Unknown\")\nstm[\"xyzzy\"] # => \"Unknown\"\n```","summary":"

Creates a new empty SplayTreeMap with a default return value for any missing key.

","abstract":false,"args":[{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"args_string":"(default_value : V)","source_link":null,"def":{"name":"new","args":[{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new do\n default_value\nend"}}],"instance_methods":[{"id":"(other:SplayTreeMap(L,W))forallL,W-instance-method","html_id":"(other:SplayTreeMap(L,W))forallL,W-instance-method","name":"<=>","doc":"Compares two SplayTreeMaps. All contained objects must also be comparable,\nor this method will trigger an exception.","summary":"

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.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"clear","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@root = nil\n@size = 0\n@header = Node(K, V).new(nil, nil)\n"}},{"id":"compact-instance-method","html_id":"compact-instance-method","name":"compact","doc":"Returns new `SplayTreeMap` that has all of the `nil` values and their\nassociated keys removed.\n\n```\nstm = SplayTreeMap.new({\"hello\" => \"world\", \"foo\" => nil})\nstm.compact # => {\"hello\" => \"world\"}\n```","summary":"

Returns new SplayTreeMap that has all of the nil values and their associated keys removed.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"compact","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each_with_object(self.class.new) do |__arg0, memo|\n key = __arg0[0]\n value = __arg0[1]\n if value.nil?\n else\n memo[key] = value\n end\nend"}},{"id":"compact!-instance-method","html_id":"compact!-instance-method","name":"compact!","doc":"Removes all `nil` values from `self`. Returns `nil` if no changes were made.\n\n```\nstm = SplayTreeMap.new({\"hello\" => \"world\", \"foo\" => nil})\nstm.compact! # => {\"hello\" => \"world\"}\nstm.compact! # => nil\n```","summary":"

Removes all nil values from self.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"compact!","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reject! do |key, value|\n value.nil?\nend"}},{"id":"delete(key,&)-instance-method","html_id":"delete(key,&)-instance-method","name":"delete","doc":"Deletes the key-value pair and returns the value, else yields *key* with given block.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.delete(\"foo\") { |key| \"#{key} not found\" } # => \"bar\"\nstm.fetch(\"foo\", nil) # => nil\nstm.delete(\"baz\") { |key| \"#{key} not found\" } # => \"baz not found\"\n```","summary":"

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.

","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":null,"block_arg":null,"return_type":"","visibility":"Public","body":"delete(key) do\n nil\nend"}},{"id":"delete_if(&):self-instance-method","html_id":"delete_if(&):self-instance-method","name":"delete_if","doc":"DEPRECATED: This is just `reject!` by another name. Use that instead.\nDeletes each key-value pair for which the given block returns `true`.\nReturns the `SplayTreeMap`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"fob\" => \"baz\", \"bar\" => \"qux\"})\nstm.delete_if { |key, value| key.starts_with?(\"fo\") }\nstm # => { \"bar\" => \"qux\" }\n```","summary":"

DEPRECATED This is just #reject! by another name.

","abstract":false,"args":[],"args_string":"(&) : self","source_link":null,"def":{"name":"delete_if","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"self","visibility":"Public","body":"reject! do |k, v|\n yield k, v\nend\nself\n"}},{"id":"dig(key:K,*subkeys)-instance-method","html_id":"dig(key:K,*subkeys)-instance-method","name":"dig","doc":"Traverses the depth of a structure and returns the value, otherwise\nraises `KeyError`.\n\n```\nh = {\"a\" => {\"b\" => [10, 20, 30]}}\nstm = SplayTreeMap.new(h)\nstm.dig \"a\", \"b\" # => [10, 20, 30]\nstm.dig \"a\", \"c\" # raises KeyError\n```","summary":"

Traverses the depth of a structure and returns the value, otherwise raises KeyError.

","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 return value.dig(*subkeys)\nend\nraise(KeyError.new(\"SplayTreeMap value not diggable for key: #{key.inspect}\"))\n"}},{"id":"dig?(key:K,*subkeys)-instance-method","html_id":"dig?(key:K,*subkeys)-instance-method","name":"dig?","doc":"Traverses the depth of a structure and returns the value.\nReturns `nil` if not found.\n\n```\nh = {\"a\" => {\"b\" => [10, 20, 30]}}\nstm = SplayTreeMap.new(h)\nstm.dig \"a\", \"b\" # => [10, 20, 30]\nstm.dig \"a\", \"c\" # => nil\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"dup","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap.new(self)"}},{"id":"each(&:Tuple(K,V)->):Nil-instance-method","html_id":"each(&:Tuple(K,V)->):Nil-instance-method","name":"each","doc":"Calls the given block for each key/value pair, passing the pair into the block.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\n\nstm.each do |key, value|\n key # => \"foo\"\n value # => \"bar\"\nend\n\nstm.each do |key_and_value|\n key_and_value # => {\"foo\", \"bar\"}\nend\n```\n\nThe enumeration follows the order the keys were inserted.","summary":"

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.

","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":null,"block_arg":null,"return_type":"","visibility":"Public","body":"key_for(value) do\n raise(KeyError.new(\"Missing key for value: #{value}\"))\nend"}},{"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 yields *value* with the given block.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.key_for(\"bar\") { |value| value.upcase } # => \"foo\"\nstm.key_for(\"qux\") { |value| value.upcase } # => \"QUX\"\n```","summary":"

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.

","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":null,"block_arg":null,"return_type":"","visibility":"Public","body":"key_for(value) do\n nil\nend"}},{"id":"keys:Array(K)-instance-method","html_id":"keys:Array(K)-instance-method","name":"keys","doc":"Returns an array of all keys in the tree.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nstm.keys.should eq [\"baz\", \"foo\"]\n```\n","summary":"

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.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L, W))"}],"args_string":"(other : Enumerable(Tuple(L, 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":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(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":3,"block_arg":null,"return_type":"","visibility":"Public","body":"other.each do |k|\n if self.has_key?(k)\n self[k] = yield k, self[k], k\n else\n self[k] = k\n end\nend\nself\n"}},{"id":"merge!(other:Enumerable(Tuple),&)-instance-method","html_id":"merge!(other:Enumerable(Tuple),&)-instance-method","name":"merge!","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(Tuple)"}],"args_string":"(other : Enumerable(Tuple), &)","source_link":null,"def":{"name":"merge!","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(Tuple)"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":null,"return_type":"","visibility":"Public","body":"other.each do |*args|\n if args[0].size == 1\n k = v = args[0][0]\n else\n k = args[0][0]\n v = args[0][-1]\n end\n if self.has_key?(k)\n self[k] = yield k, self[k], v\n else\n self[k] = v\n end\nend\nself\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":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)), &) 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":null,"return_type":"","visibility":"Public","body":"other.each do |k, v|\n if self.has_key?(k)\n self[k] = yield k, self[k], v\n else\n self[k] = v\n end\nend\nself\n"}},{"id":"merge!(other:T)forallT-instance-method","html_id":"merge!(other:T)forallT-instance-method","name":"merge!","doc":"Adds the contents of *other* to this `SplayTreeMap`.\n\nFor Array-like structures, which return a single value to the block passed\nto `#each`, that value will be used for both the key and the value.\n\nFor Array-like structures, where each array element is a two value Tuple,\nthe first value of the Tuple will be the key, and the second will be the\nvalue.\n\nFor Hash-like structures, which pass a key/value tuple into the `#each`,\nthe key and value will be used for the key and value in the tree entry.\n\nIf a Tuple is passed into the `#each` that has more or fewer than 2 elements,\nthe key for the tree entry will come from the first element in the Tuple, and\nthe value will come from the last element in the Tuple.\n\n```\na = [] of Int32\n10.times {|x| a << x}\nstm = SplayTreeMap(Int32, Int32).new({6 => 0, 11 => 0}).merge!(a)\nstm[11] # => 0\nstm[6] # => 6\n\nh = {} of Int32 => Int32\n10.times {|x| h[x] = x**2}\nstm = SplayTreeMap(Int32, Int32).new.merge!(h)\nstm[6] # => 36\n\nstm = SplayTreeMap(Int32, Int32).new.merge!({ {4,16},{5},{7,49,343} })\nstm[4] # => 16\nstm[5] # => 5\nstm[7] # => 343\n","summary":"

Adds the contents of other to this SplayTreeMap.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"T"}],"args_string":"(other : T) forall T","source_link":null,"def":{"name":"merge!","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"T"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self.merge!(other) do |k, v1, v2|\n v2\nend"}},{"id":"min-instance-method","html_id":"min-instance-method","name":"min","doc":"Returns the smallest key in the tree.","summary":"

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.

","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":"reject(keys:Array|Tuple)-instance-method","html_id":"reject(keys:Array|Tuple)-instance-method","name":"reject","doc":"Removes a list of keys out of the tree, returning a new tree.\n\n```\nh = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject(\"a\", \"c\")\nh # => {\"b\" => 2, \"d\" => 4}\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"reject","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K, V).new) do |__arg1, memo|\n k = __arg1[0]\n v = __arg1[1]\n if yield k, v\n else\n memo[k] = v\n end\nend"}},{"id":"reject!(&block:K,V->_)-instance-method","html_id":"reject!(&block:K,V->_)-instance-method","name":"reject!","doc":"Equivalent to `SplayTreeMap#reject`, but modifies the current object rather than\nreturning a new one. Returns `nil` if no changes were made.","summary":"

Equivalent to SplayTreeMap#reject, but modifies the current object rather than returning a new one.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"reject!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"num_entries = size\nkeys_to_delete = [] of K\neach do |key, value|\n if yield key, value\n keys_to_delete << key\n end\nend\nkeys_to_delete.each do |key|\n delete(key)\nend\nnum_entries == size ? nil : self\n"}},{"id":"reject!(keys:Array|Tuple)-instance-method","html_id":"reject!(keys:Array|Tuple)-instance-method","name":"reject!","doc":"Removes a list of keys out of the tree.\n\n```\nh = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject!(\"a\", \"c\")\nh # => {\"b\" => 2, \"d\" => 4}\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"select","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"reject do |k, v|\n !(yield k, v)\nend"}},{"id":"select(keys:Array|Tuple)-instance-method","html_id":"select(keys:Array|Tuple)-instance-method","name":"select","doc":"Returns a new `SplayTreeMap` with the given keys.\n\n```\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select({\"a\", \"c\"}) # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select(\"a\", \"c\") # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select([\"a\", \"c\"]) # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

Returns a new SplayTreeMap with the given keys.

","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":"stm = SplayTreeMap(K, V).new\nkeys.each do |k|\n k = k.as(K)\n if has_key?(k)\n stm[k] = obtain(k)\n end\nend\nstm\n"}},{"id":"select(*keys)-instance-method","html_id":"select(*keys)-instance-method","name":"select","doc":"Returns a new `SplayTreeMap` with the given keys.\n\n```\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select({\"a\", \"c\"}) # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select(\"a\", \"c\") # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select([\"a\", \"c\"]) # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

Returns a new SplayTreeMap with the given keys.

","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":"self.select(keys)"}},{"id":"select!(*keys)-instance-method","html_id":"select!(*keys)-instance-method","name":"select!","doc":"Removes every element except the given ones.\n\n```\nh1 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!({\"a\", \"c\"})\nh2 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!(\"a\", \"c\")\nh3 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!([\"a\", \"c\"])\nh1 == h2 == h3 # => true\nh1 # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"select!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"reject! do |k, v|\n !(yield k, v)\nend"}},{"id":"select!(keys:Array|Tuple)-instance-method","html_id":"select!(keys:Array|Tuple)-instance-method","name":"select!","doc":"Removes every element except the given ones.\n\n```\nh1 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!({\"a\", \"c\"})\nh2 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!(\"a\", \"c\")\nh3 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!([\"a\", \"c\"])\nh1 == h2 == h3 # => true\nh1 # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

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)).

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"to_a","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"a = Array(::Tuple(K, V)).new\neach do |k, v|\n a << {k, v}\nend\na\n"}},{"id":"to_h-instance-method","html_id":"to_h-instance-method","name":"to_h","doc":"Transform a `SplayTreeMap(K,V)` into a `Hash(K,V)`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nh = stm.to_h # => {\"baz\" => \"qux\", \"foo\" => \"bar\"}\n```","summary":"

Transform a SplayTreeMap(K,V) into a Hash(K,V).

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"to_h","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"h = Hash(K, V).new\neach do |k, v|\n h[k] = v\nend\nh\n"}},{"id":"to_s(io:IO):Nil-instance-method","html_id":"to_s(io:IO):Nil-instance-method","name":"to_s","doc":"Transform the `SplayTreeMap` into a `String` representation.","summary":"

Transform the SplayTreeMap into a String representation.

","abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : Nil","source_link":null,"def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":"IO"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"final = self.size\ncount = 0\nio << String.build do |buff|\n buff << \"{ \"\n self.each do |k, v|\n count = count + 1\n buff << k.inspect\n buff << \" => \"\n buff << v.inspect\n if count < final\n buff << \", \"\n end\n end\n buff << \" }\"\nend\n"}},{"id":"transform(&block:Tuple(K,V)->Tuple(K2,V2))forallK2,V2-instance-method","html_id":"transform(&block:Tuple(K,V)->Tuple(K2,V2))forallK2,V2-instance-method","name":"transform","doc":"Returns a new `SplayTreeMap` with all of the key/value pairs converted using\nthe provided block. The block can change the types of both keys and values.\n\n```\nstm = SplayTreeMap({1 => 1, 2 => 4, 3 => 9, 4 => 16})\nstm = stm.transform {|k, v| {k.to_s, v.to_s}}\nstm # => {\"1\" => \"1\", \"2\" => \"4\", \"3\" => \"9\", \"4\" => \"16\"}\n```\n","summary":"

Returns a new SplayTreeMap with all of the key/value pairs converted using the provided block.

","abstract":false,"args":[],"args_string":"(&block : Tuple(K, V) -> Tuple(K2, V2)) forall K2, V2","source_link":null,"def":{"name":"transform","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(::Tuple(K, V) -> ::Tuple(K2, V2))"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K2, V2).new) do |__arg2, memo|\n key = __arg2[0]\n value = __arg2[1]\n key2, value2 = yield {key, value}\n memo[key2] = value2\nend"}},{"id":"transform_keys(&block:K->K2)forallK2-instance-method","html_id":"transform_keys(&block:K->K2)forallK2-instance-method","name":"transform_keys","doc":"Returns a new `SplayTreeMap` with all keys converted using the block operation.\nThe block can change a type of keys.\n\n```\nstm = SplayTreeMap.new({:a => 1, :b => 2, :c => 3})\nstm.transform_keys { |key| key.to_s } # => {\"a\" => 1, \"b\" => 2, \"c\" => 3}\n```","summary":"

Returns a new SplayTreeMap with all keys converted using the block operation.

","abstract":false,"args":[],"args_string":"(&block : K -> K2) forall K2","source_link":null,"def":{"name":"transform_keys","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K -> K2)"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K2, V).new) do |__arg3, memo|\n key = __arg3[0]\n value = __arg3[1]\n memo[yield key] = value\nend"}},{"id":"transform_values(&block:V->V2)forallV2-instance-method","html_id":"transform_values(&block:V->V2)forallV2-instance-method","name":"transform_values","doc":"Returns a new SplayTreeMap with all values converted using the block operation.\nThe block can change a type of values.\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":"

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.

","abstract":false,"args":[],"args_string":"(&block : V -> V)","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 -> V)"},"return_type":"","visibility":"Public","body":"each do |key, value|\n memo[key] = yield value\nend\nself\n"}},{"id":"values:Array(V)-instance-method","html_id":"values:Array(V)-instance-method","name":"values","doc":"Returns an array containing all of the values in the tree. The array is in\nthe order of the associated keys.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4})\nstm.values # => [1, 2, 3, 4]\n```\n","summary":"

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

","class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[]}]}} \ No newline at end of file +{"repository_name":"Splay Tree Map","body":"# Splay Tree Map\n\n[![GitHub release](https://img.shields.io/github/release/wyhaines/splay_tree_map.cr.svg)](https://github.com/wyhaines/splay_tree_map.cr/releases)\n\nA splay tree is a type of binary search tree that self organizes so that the\nmost frequently accessed items tend to be towards the root of the tree, where\nthey can be accessed more quickly.\n\nThis implementation provides a hash-like interface, and it provides a couple\nfeatures not typically found in Splay Trees -- efficient removal of the items\nthat are generally least frequently accessed, and an extra fast search option.\n\n### Leaf Pruning\n\nBecause splay trees tend to organize themselves with the most frequently\naccessed elements towards the root of the tree, the least frequently accessed\nitems tend to migrate towards the leaves of the tree. This implementation\noffers a method that can be used to prune its leaves, which generally has the\neffect of removing the least frequently accessed items from the tree.\n\nThis is useful if the data structure is being used to implement a cache, as\nit can be used to control the size of the cache while generaly keeping the\nmost useful items in the cache without any other extensive bookkeeping.\n\n### Search without Splaying\n\nA splay operation is generally performed on any access to a splay tree. This is\nthe operation that moves the most important items towards the root. This operation\nhas a cost to it, however, and there are times when it is desireable to search the\nhash without a splay operation occuring for the key that is searched. This results\nin a faster search operation, at the cost of not performing any efficiency improving\nstructural changes to the tree. This should not be the primary search method that\nis used, but it can be useful at the right time.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n stm:\n github: wyhaines/splay_tree_map.cr\n ```\n\n2. Run `shards install`\n\n## Usage\n\nFull documentation can be found at: [https://wyhaines.github.io/splay_tree_map.cr/index.html](https://wyhaines.github.io/splay_tree_map.cr/index.html)\n\n```crystal\nrequire \"splay_tree_map\"\n```\n\nGenerally, the data structure is used like a hash.\n\n```crystal\nstm = SplayTreeMap(String, String).new\n\nstm[\"this\"] = \"that\"\nstm[\"something\"] = \"else\"\nstm[\"junk\"] = \"pile\"\n\nif stm.has_key?(\"this\")\n puts stm[\"this\"]\nend\n\nstm.delete(\"junk\")\n\nputs stm.obtain(\"something\") # This finds, but doesn't splay.\n\nstm.prune # remove all leaves\n```\n\n## TODO\n\nExperiment with other variations of splay operations, such as lazy semi-splay\nto see if performance can be improved. Right now this isn't any better than\njust using a Hash and arbitrarily deleting half of the hash if it grows too big.\n\n## Credits\n\nThis implementation is derived from the incomplete and broken implementation\nin the Crystalline shard found at https://github.com/jtomschroeder/crystalline\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Kirk Haines](https://github.com/wyhaines) - creator and maintainer\n","program":{"html_id":"Splay Tree Map/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"Splay Tree Map","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"Splay Tree Map/SplayTreeMap","path":"SplayTreeMap.html","kind":"class","full_name":"SplayTreeMap(K, V)","name":"SplayTreeMap","abstract":false,"superclass":{"html_id":"Splay Tree Map/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Splay Tree Map/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Splay Tree Map/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"Splay Tree Map/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"Splay Tree Map/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Splay Tree Map/Object","kind":"class","full_name":"Object","name":"Object"}],"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":[{"html_id":"Splay Tree Map/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Splay Tree Map/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"Splay Tree Map/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[{"id":"zip(ary1:Array(K),ary2:Array(V))-class-method","html_id":"zip(ary1:Array(K),ary2:Array(V))-class-method","name":"zip","doc":"Zips two arrays into a `SplayTreeMap`, taking keys from *ary1* and values from *ary2*.\n\n```\nSplayTreeMap.zip([\"key1\", \"key2\", \"key3\"], [\"value1\", \"value2\", \"value3\"])\n# => {\"key1\" => \"value1\", \"key2\" => \"value2\", \"key3\" => \"value3\"}\n```","summary":"

Zips two arrays into a SplayTreeMap, taking keys from ary1 and values from ary2.

","abstract":false,"args":[{"name":"ary1","doc":null,"default_value":"","external_name":"ary1","restriction":"Array(K)"},{"name":"ary2","doc":null,"default_value":"","external_name":"ary2","restriction":"Array(V)"}],"args_string":"(ary1 : Array(K), ary2 : Array(V))","source_link":null,"def":{"name":"zip","args":[{"name":"ary1","doc":null,"default_value":"","external_name":"ary1","restriction":"Array(K)"},{"name":"ary2","doc":null,"default_value":"","external_name":"ary2","restriction":"Array(V)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K, V).new\nary1.each_with_index do |key, i|\n stm[key] = ary2[i]\nend\nstm\n"}}],"constructors":[{"id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,block:SplayTreeMap(K,V),K->V?=nil)-class-method","html_id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,block:SplayTreeMap(K,V),K->V?=nil)-class-method","name":"new","doc":"Creates a new empty `SplayTreeMap` with a *block* that is called when a key is\nmissing from the tree.\n\n```\nstm = SplayTreeMap(String, Array(Int32)).new { |t, k| t[k] = [] of Int32 }\nstm[\"a\"] << 1\nstm[\"a\"] << 2\nstm[\"a\"] << 3\nputs stm.inspect # => [1,2,3]\n```","summary":"

Creates a new empty SplayTreeMap with a block that is called when a key is missing from the tree.

","abstract":false,"args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"block","doc":null,"default_value":"nil","external_name":"block","restriction":"(SplayTreeMap(K, V), K -> V) | ::Nil"}],"args_string":"(seed : Enumerable(Tuple(K, V))? | Iterable(Tuple(K, V))? = nil, block : SplayTreeMap(K, V), K -> V? = nil)","source_link":null,"def":{"name":"new","args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"block","doc":null,"default_value":"nil","external_name":"block","restriction":"(SplayTreeMap(K, V), K -> V) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = SplayTreeMap(K, V).allocate\n_.initialize(seed, block)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,&block:SplayTreeMap(K,V),K->V)-class-method","html_id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,&block:SplayTreeMap(K,V),K->V)-class-method","name":"new","doc":"Creates a new empty `SplayTreeMap` with a *block* that is called when a key is\nmissing from the tree.\n\n```\nstm = SplayTreeMap(String, Array(Int32)).new { |t, k| t[k] = [] of Int32 }\nstm[\"a\"] << 1\nstm[\"a\"] << 2\nstm[\"a\"] << 3\nputs stm.inspect # => [1,2,3]\n```","summary":"

Creates a new empty SplayTreeMap with a block that is called when a key is missing from the tree.

","abstract":false,"args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"}],"args_string":"(seed : Enumerable(Tuple(K, V))? | Iterable(Tuple(K, V))? = nil, &block : SplayTreeMap(K, V), K -> V)","source_link":null,"def":{"name":"new","args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(SplayTreeMap(K, V), K -> V)"},"return_type":"","visibility":"Public","body":"new(seed: seed, block: block)"}},{"id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?,default_value:V)-class-method","html_id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?,default_value:V)-class-method","name":"new","doc":"Creates a new `SplayTreeMap`, populating it with values from the *Enumerable*\nor the *Iterable* seed object, and with a default return value for any missing\nkey.\n\n```\nstm = SplayTreeMap.new({\"this\" => \"that\", \"something\" => \"else\"}, \"Unknown\")\nstm[\"something\"] # => \"else\"\nstm[\"xyzzy\"] # => \"Unknown\"\n```","summary":"

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.

","abstract":false,"args":[{"name":"seed","doc":null,"default_value":"","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"args_string":"(seed : Enumerable(Tuple(K, V))? | Iterable(Tuple(K, V))?, default_value : V)","source_link":null,"def":{"name":"new","args":[{"name":"seed","doc":null,"default_value":"","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new(seed: seed) do\n default_value\nend"}},{"id":"new(default_value:V)-class-method","html_id":"new(default_value:V)-class-method","name":"new","doc":"Creates a new empty `SplayTreeMap` with a default return value for any missing key.\n\n```\nstm = SplayTreeMap(String, String).new(\"Unknown\")\nstm[\"xyzzy\"] # => \"Unknown\"\n```","summary":"

Creates a new empty SplayTreeMap with a default return value for any missing key.

","abstract":false,"args":[{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"args_string":"(default_value : V)","source_link":null,"def":{"name":"new","args":[{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new do\n default_value\nend"}}],"instance_methods":[{"id":"(other:SplayTreeMap(L,W))forallL,W-instance-method","html_id":"(other:SplayTreeMap(L,W))forallL,W-instance-method","name":"<=>","doc":"Compares two SplayTreeMaps. All contained objects must also be comparable,\nor this method will trigger an exception.","summary":"

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.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"clear","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@root = nil\n@size = 0\n@header = Node(K, V).new(nil, nil)\n"}},{"id":"compact-instance-method","html_id":"compact-instance-method","name":"compact","doc":"Returns new `SplayTreeMap` that has all of the `nil` values and their\nassociated keys removed.\n\n```\nstm = SplayTreeMap.new({\"hello\" => \"world\", \"foo\" => nil})\nstm.compact # => {\"hello\" => \"world\"}\n```","summary":"

Returns new SplayTreeMap that has all of the nil values and their associated keys removed.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"compact","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each_with_object(self.class.new) do |__arg0, memo|\n key = __arg0[0]\n value = __arg0[1]\n if value.nil?\n else\n memo[key] = value\n end\nend"}},{"id":"compact!-instance-method","html_id":"compact!-instance-method","name":"compact!","doc":"Removes all `nil` values from `self`. Returns `nil` if no changes were made.\n\n```\nstm = SplayTreeMap.new({\"hello\" => \"world\", \"foo\" => nil})\nstm.compact! # => {\"hello\" => \"world\"}\nstm.compact! # => nil\n```","summary":"

Removes all nil values from self.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"compact!","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reject! do |key, value|\n value.nil?\nend"}},{"id":"delete(key,&)-instance-method","html_id":"delete(key,&)-instance-method","name":"delete","doc":"Deletes the key-value pair and returns the value, else yields *key* with given block.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.delete(\"foo\") { |key| \"#{key} not found\" } # => \"bar\"\nstm.fetch(\"foo\", nil) # => nil\nstm.delete(\"baz\") { |key| \"#{key} not found\" } # => \"baz not found\"\n```","summary":"

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.

","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":null,"block_arg":null,"return_type":"","visibility":"Public","body":"delete(key) do\n nil\nend"}},{"id":"delete_if(&):self-instance-method","html_id":"delete_if(&):self-instance-method","name":"delete_if","doc":"DEPRECATED: This is just `reject!` by another name. Use that instead.\nDeletes each key-value pair for which the given block returns `true`.\nReturns the `SplayTreeMap`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"fob\" => \"baz\", \"bar\" => \"qux\"})\nstm.delete_if { |key, value| key.starts_with?(\"fo\") }\nstm # => { \"bar\" => \"qux\" }\n```","summary":"

DEPRECATED This is just #reject! by another name.

","abstract":false,"args":[],"args_string":"(&) : self","source_link":null,"def":{"name":"delete_if","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"self","visibility":"Public","body":"reject! do |k, v|\n yield k, v\nend\nself\n"}},{"id":"dig(key:K,*subkeys)-instance-method","html_id":"dig(key:K,*subkeys)-instance-method","name":"dig","doc":"Traverses the depth of a structure and returns the value, otherwise\nraises `KeyError`.\n\n```\nh = {\"a\" => {\"b\" => [10, 20, 30]}}\nstm = SplayTreeMap.new(h)\nstm.dig \"a\", \"b\" # => [10, 20, 30]\nstm.dig \"a\", \"c\" # raises KeyError\n```","summary":"

Traverses the depth of a structure and returns the value, otherwise raises KeyError.

","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 return value.dig(*subkeys)\nend\nraise(KeyError.new(\"SplayTreeMap value not diggable for key: #{key.inspect}\"))\n"}},{"id":"dig?(key:K,*subkeys)-instance-method","html_id":"dig?(key:K,*subkeys)-instance-method","name":"dig?","doc":"Traverses the depth of a structure and returns the value.\nReturns `nil` if not found.\n\n```\nh = {\"a\" => {\"b\" => [10, 20, 30]}}\nstm = SplayTreeMap.new(h)\nstm.dig \"a\", \"b\" # => [10, 20, 30]\nstm.dig \"a\", \"c\" # => nil\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"dup","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap.new(self)"}},{"id":"each(&:Tuple(K,V)->):Nil-instance-method","html_id":"each(&:Tuple(K,V)->):Nil-instance-method","name":"each","doc":"Calls the given block for each key/value pair, passing the pair into the block.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\n\nstm.each do |key, value|\n key # => \"foo\"\n value # => \"bar\"\nend\n\nstm.each do |key_and_value|\n key_and_value # => {\"foo\", \"bar\"}\nend\n```\n\nThe enumeration follows the order the keys were inserted.","summary":"

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.

","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":null,"block_arg":null,"return_type":"","visibility":"Public","body":"key_for(value) do\n raise(KeyError.new(\"Missing key for value: #{value}\"))\nend"}},{"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 yields *value* with the given block.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.key_for(\"bar\") { |value| value.upcase } # => \"foo\"\nstm.key_for(\"qux\") { |value| value.upcase } # => \"QUX\"\n```","summary":"

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.

","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":null,"block_arg":null,"return_type":"","visibility":"Public","body":"key_for(value) do\n nil\nend"}},{"id":"keys:Array(K)-instance-method","html_id":"keys:Array(K)-instance-method","name":"keys","doc":"Returns an array of all keys in the tree.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nstm.keys.should eq [\"baz\", \"foo\"]\n```\n","summary":"

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.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L, W))"}],"args_string":"(other : Enumerable(Tuple(L, 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":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(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":3,"block_arg":null,"return_type":"","visibility":"Public","body":"other.each do |k|\n if self.has_key?(k)\n self[k] = yield k, self[k], k\n else\n self[k] = k\n end\nend\nself\n"}},{"id":"merge!(other:Enumerable(Tuple),&)-instance-method","html_id":"merge!(other:Enumerable(Tuple),&)-instance-method","name":"merge!","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(Tuple)"}],"args_string":"(other : Enumerable(Tuple), &)","source_link":null,"def":{"name":"merge!","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(Tuple)"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":null,"return_type":"","visibility":"Public","body":"other.each do |*args|\n if args[0].size == 1\n k = v = args[0][0]\n else\n k = args[0][0]\n v = args[0][-1]\n end\n if self.has_key?(k)\n self[k] = yield k, self[k], v\n else\n self[k] = v\n end\nend\nself\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":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)), &) 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":null,"return_type":"","visibility":"Public","body":"other.each do |k, v|\n if self.has_key?(k)\n self[k] = yield k, self[k], v\n else\n self[k] = v\n end\nend\nself\n"}},{"id":"merge!(other:T)forallT-instance-method","html_id":"merge!(other:T)forallT-instance-method","name":"merge!","doc":"Adds the contents of *other* to this `SplayTreeMap`.\n\nFor Array-like structures, which return a single value to the block passed\nto `#each`, that value will be used for both the key and the value.\n\nFor Array-like structures, where each array element is a two value Tuple,\nthe first value of the Tuple will be the key, and the second will be the\nvalue.\n\nFor Hash-like structures, which pass a key/value tuple into the `#each`,\nthe key and value will be used for the key and value in the tree entry.\n\nIf a Tuple is passed into the `#each` that has more or fewer than 2 elements,\nthe key for the tree entry will come from the first element in the Tuple, and\nthe value will come from the last element in the Tuple.\n\n```\na = [] of Int32\n10.times {|x| a << x}\nstm = SplayTreeMap(Int32, Int32).new({6 => 0, 11 => 0}).merge!(a)\nstm[11] # => 0\nstm[6] # => 6\n\nh = {} of Int32 => Int32\n10.times {|x| h[x] = x**2}\nstm = SplayTreeMap(Int32, Int32).new.merge!(h)\nstm[6] # => 36\n\nstm = SplayTreeMap(Int32, Int32).new.merge!({ {4,16},{5},{7,49,343} })\nstm[4] # => 16\nstm[5] # => 5\nstm[7] # => 343\n","summary":"

Adds the contents of other to this SplayTreeMap.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"T"}],"args_string":"(other : T) forall T","source_link":null,"def":{"name":"merge!","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"T"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self.merge!(other) do |k, v1, v2|\n v2\nend"}},{"id":"min-instance-method","html_id":"min-instance-method","name":"min","doc":"Returns the smallest key in the tree.","summary":"

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.

","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":"reject(keys:Array|Tuple)-instance-method","html_id":"reject(keys:Array|Tuple)-instance-method","name":"reject","doc":"Removes a list of keys out of the tree, returning a new tree.\n\n```\nh = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject(\"a\", \"c\")\nh # => {\"b\" => 2, \"d\" => 4}\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"reject","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K, V).new) do |__arg1, memo|\n k = __arg1[0]\n v = __arg1[1]\n if yield k, v\n else\n memo[k] = v\n end\nend"}},{"id":"reject!(&block:K,V->_)-instance-method","html_id":"reject!(&block:K,V->_)-instance-method","name":"reject!","doc":"Equivalent to `SplayTreeMap#reject`, but modifies the current object rather than\nreturning a new one. Returns `nil` if no changes were made.","summary":"

Equivalent to SplayTreeMap#reject, but modifies the current object rather than returning a new one.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"reject!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"num_entries = size\nkeys_to_delete = [] of K\neach do |key, value|\n if yield key, value\n keys_to_delete << key\n end\nend\nkeys_to_delete.each do |key|\n delete(key)\nend\nnum_entries == size ? nil : self\n"}},{"id":"reject!(keys:Array|Tuple)-instance-method","html_id":"reject!(keys:Array|Tuple)-instance-method","name":"reject!","doc":"Removes a list of keys out of the tree.\n\n```\nh = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject!(\"a\", \"c\")\nh # => {\"b\" => 2, \"d\" => 4}\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"select","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"reject do |k, v|\n !(yield k, v)\nend"}},{"id":"select(keys:Array|Tuple)-instance-method","html_id":"select(keys:Array|Tuple)-instance-method","name":"select","doc":"Returns a new `SplayTreeMap` with the given keys.\n\n```\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select({\"a\", \"c\"}) # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select(\"a\", \"c\") # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select([\"a\", \"c\"]) # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

Returns a new SplayTreeMap with the given keys.

","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":"stm = SplayTreeMap(K, V).new\nkeys.each do |k|\n k = k.as(K)\n if has_key?(k)\n stm[k] = obtain(k)\n end\nend\nstm\n"}},{"id":"select(*keys)-instance-method","html_id":"select(*keys)-instance-method","name":"select","doc":"Returns a new `SplayTreeMap` with the given keys.\n\n```\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select({\"a\", \"c\"}) # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select(\"a\", \"c\") # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select([\"a\", \"c\"]) # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

Returns a new SplayTreeMap with the given keys.

","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":"self.select(keys)"}},{"id":"select!(*keys)-instance-method","html_id":"select!(*keys)-instance-method","name":"select!","doc":"Removes every element except the given ones.\n\n```\nh1 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!({\"a\", \"c\"})\nh2 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!(\"a\", \"c\")\nh3 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!([\"a\", \"c\"])\nh1 == h2 == h3 # => true\nh1 # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"select!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"reject! do |k, v|\n !(yield k, v)\nend"}},{"id":"select!(keys:Array|Tuple)-instance-method","html_id":"select!(keys:Array|Tuple)-instance-method","name":"select!","doc":"Removes every element except the given ones.\n\n```\nh1 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!({\"a\", \"c\"})\nh2 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!(\"a\", \"c\")\nh3 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!([\"a\", \"c\"])\nh1 == h2 == h3 # => true\nh1 # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

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)).

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"to_a","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"a = Array(::Tuple(K, V)).new\neach do |k, v|\n a << {k, v}\nend\na\n"}},{"id":"to_h-instance-method","html_id":"to_h-instance-method","name":"to_h","doc":"Transform a `SplayTreeMap(K,V)` into a `Hash(K,V)`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nh = stm.to_h # => {\"baz\" => \"qux\", \"foo\" => \"bar\"}\n```","summary":"

Transform a SplayTreeMap(K,V) into a Hash(K,V).

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"to_h","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"h = Hash(K, V).new\neach do |k, v|\n h[k] = v\nend\nh\n"}},{"id":"to_s(io:IO):Nil-instance-method","html_id":"to_s(io:IO):Nil-instance-method","name":"to_s","doc":"Transform the `SplayTreeMap` into a `String` representation.","summary":"

Transform the SplayTreeMap into a String representation.

","abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : Nil","source_link":null,"def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":"IO"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"final = self.size\ncount = 0\nio << String.build do |buff|\n buff << \"{ \"\n self.each do |k, v|\n count = count + 1\n buff << k.inspect\n buff << \" => \"\n buff << v.inspect\n if count < final\n buff << \", \"\n end\n end\n buff << \" }\"\nend\n"}},{"id":"transform(&block:Tuple(K,V)->Tuple(K2,V2))forallK2,V2-instance-method","html_id":"transform(&block:Tuple(K,V)->Tuple(K2,V2))forallK2,V2-instance-method","name":"transform","doc":"Returns a new `SplayTreeMap` with all of the key/value pairs converted using\nthe provided block. The block can change the types of both keys and values.\n\n```\nstm = SplayTreeMap({1 => 1, 2 => 4, 3 => 9, 4 => 16})\nstm = stm.transform {|k, v| {k.to_s, v.to_s}}\nstm # => {\"1\" => \"1\", \"2\" => \"4\", \"3\" => \"9\", \"4\" => \"16\"}\n```\n","summary":"

Returns a new SplayTreeMap with all of the key/value pairs converted using the provided block.

","abstract":false,"args":[],"args_string":"(&block : Tuple(K, V) -> Tuple(K2, V2)) forall K2, V2","source_link":null,"def":{"name":"transform","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(::Tuple(K, V) -> ::Tuple(K2, V2))"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K2, V2).new) do |__arg2, memo|\n key = __arg2[0]\n value = __arg2[1]\n key2, value2 = yield {key, value}\n memo[key2] = value2\nend"}},{"id":"transform_keys(&block:K->K2)forallK2-instance-method","html_id":"transform_keys(&block:K->K2)forallK2-instance-method","name":"transform_keys","doc":"Returns a new `SplayTreeMap` with all keys converted using the block operation.\nThe block can change a type of keys.\n\n```\nstm = SplayTreeMap.new({:a => 1, :b => 2, :c => 3})\nstm.transform_keys { |key| key.to_s } # => {\"a\" => 1, \"b\" => 2, \"c\" => 3}\n```","summary":"

Returns a new SplayTreeMap with all keys converted using the block operation.

","abstract":false,"args":[],"args_string":"(&block : K -> K2) forall K2","source_link":null,"def":{"name":"transform_keys","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K -> K2)"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K2, V).new) do |__arg3, memo|\n key = __arg3[0]\n value = __arg3[1]\n memo[yield key] = value\nend"}},{"id":"transform_values(&block:V->V2)forallV2-instance-method","html_id":"transform_values(&block:V->V2)forallV2-instance-method","name":"transform_values","doc":"Returns a new SplayTreeMap with all values converted using the block operation.\nThe block can change a type of values.\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":"

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.

","abstract":false,"args":[],"args_string":"(&block : V -> V)","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 -> V)"},"return_type":"","visibility":"Public","body":"each do |key, value|\n memo[key] = yield value\nend\nself\n"}},{"id":"values:Array(V)-instance-method","html_id":"values:Array(V)-instance-method","name":"values","doc":"Returns an array containing all of the values in the tree. The array is in\nthe order of the associated keys.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4})\nstm.values # => [1, 2, 3, 4]\n```\n","summary":"

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

","class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[]}]}} \ No newline at end of file diff --git a/docs/search-index.js b/docs/search-index.js index 624487d..7c5cc53 100644 --- a/docs/search-index.js +++ b/docs/search-index.js @@ -1 +1 @@ -crystal_doc_search_index_callback({"repository_name":"Splay Tree Map","body":"# Splay Tree Map\n\nA splay tree is a type of binary search tree that self organizes so that the\nmost frequently accessed items tend to be towards the root of the tree, where\nthey can be accessed more quickly.\n\nThis implementation provides a hash-like interface, and it provides a couple\nfeatures not typically found in Splay Trees -- efficient removal of the items\nthat are generally least frequently accessed, and an extra fast search option.\n\n### Leaf Pruning\n\nBecause splay trees tend to organize themselves with the most frequently\naccessed elements towards the root of the tree, the least frequently accessed\nitems tend to migrate towards the leaves of the tree. This implementation\noffers a method that can be used to prune its leaves, which generally has the\neffect of removing the least frequently accessed items from the hash.\n\nThis is useful if the data structure is being used to implement a cache, as\nit can be used to control the size of the cache while generaly keeping the\nmost useful items in the cache without any other extensive bookkeeping.\n\n### Search without Splaying\n\nA splay operation is generally performed on any access to a splay tree. This is\nthe operation that moves the most important items towards the root. This operation\nhas a cost to it, however, and there are times when it is desireable to search the\nhash without a splay operation occuring for the key that is searched. This results\nin a faster search operation, at the cost of not performing any efficiency improving\nstructural changes to the tree. This should not be the primary search method that\nis used, but it can be useful at the right time.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n stm:\n github: wyhaines/splay_tree_map.cr\n ```\n\n2. Run `shards install`\n\n## Usage\n\nFull documentation can be found at: https://wyhaines.github.io/splay_tree_map.cr/index.html\n\n```crystal\nrequire \"splay_tree_map\"\n```\n\nGenerally, the data structure is used like a hash.\n\n```crystal\nstm = SplayTreeMap(String, String).new\n\nstm[\"this\"] = \"that\"\nstm[\"something\"] = \"else\"\nstm[\"junk\"] = \"pile\"\n\nif stm.has_key?(\"this\")\n puts stm[\"this\"]\nend\n\nstm.delete(\"junk\")\n\nputs stm.find(\"something\") # This finds, but doesn't splay.\n\nstm.prune # remove all leaves\n```\n\n## TODO\n\nExperiment with other variations of splay operations, such as lazy semi-splay\nto see if performance can be improved. Right now this isn't any better than\njust using a Hash and arbitrarily deleting half of the hash if it grows too big.\n\n## Credits\n\nThis implementation is derived from the incomplete and broken implementation\nin the Crystalline shard found at https://github.com/jtomschroeder/crystalline\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Kirk Haines](https://github.com/wyhaines) - creator and maintainer\n","program":{"html_id":"Splay Tree Map/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"Splay Tree Map","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"Splay Tree Map/SplayTreeMap","path":"SplayTreeMap.html","kind":"class","full_name":"SplayTreeMap(K, V)","name":"SplayTreeMap","abstract":false,"superclass":{"html_id":"Splay Tree Map/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Splay Tree Map/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Splay Tree Map/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"Splay Tree Map/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"Splay Tree Map/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Splay Tree Map/Object","kind":"class","full_name":"Object","name":"Object"}],"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":[{"html_id":"Splay Tree Map/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Splay Tree Map/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"Splay Tree Map/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[{"id":"zip(ary1:Array(K),ary2:Array(V))-class-method","html_id":"zip(ary1:Array(K),ary2:Array(V))-class-method","name":"zip","doc":"Zips two arrays into a `SplayTreeMap`, taking keys from *ary1* and values from *ary2*.\n\n```\nSplayTreeMap.zip([\"key1\", \"key2\", \"key3\"], [\"value1\", \"value2\", \"value3\"])\n# => {\"key1\" => \"value1\", \"key2\" => \"value2\", \"key3\" => \"value3\"}\n```","summary":"

Zips two arrays into a SplayTreeMap, taking keys from ary1 and values from ary2.

","abstract":false,"args":[{"name":"ary1","doc":null,"default_value":"","external_name":"ary1","restriction":"Array(K)"},{"name":"ary2","doc":null,"default_value":"","external_name":"ary2","restriction":"Array(V)"}],"args_string":"(ary1 : Array(K), ary2 : Array(V))","source_link":null,"def":{"name":"zip","args":[{"name":"ary1","doc":null,"default_value":"","external_name":"ary1","restriction":"Array(K)"},{"name":"ary2","doc":null,"default_value":"","external_name":"ary2","restriction":"Array(V)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K, V).new\nary1.each_with_index do |key, i|\n stm[key] = ary2[i]\nend\nstm\n"}}],"constructors":[{"id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,block:SplayTreeMap(K,V),K->V?=nil)-class-method","html_id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,block:SplayTreeMap(K,V),K->V?=nil)-class-method","name":"new","doc":"Creates a new empty `SplayTreeMap` with a *block* that is called when a key is\nmissing from the tree.\n\n```\nstm = SplayTreeMap(String, Array(Int32)).new { |t, k| t[k] = [] of Int32 }\nstm[\"a\"] << 1\nstm[\"a\"] << 2\nstm[\"a\"] << 3\nputs stm.inspect # => [1,2,3]\n```","summary":"

Creates a new empty SplayTreeMap with a block that is called when a key is missing from the tree.

","abstract":false,"args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"block","doc":null,"default_value":"nil","external_name":"block","restriction":"(SplayTreeMap(K, V), K -> V) | ::Nil"}],"args_string":"(seed : Enumerable(Tuple(K, V))? | Iterable(Tuple(K, V))? = nil, block : SplayTreeMap(K, V), K -> V? = nil)","source_link":null,"def":{"name":"new","args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"block","doc":null,"default_value":"nil","external_name":"block","restriction":"(SplayTreeMap(K, V), K -> V) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = SplayTreeMap(K, V).allocate\n_.initialize(seed, block)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,&block:SplayTreeMap(K,V),K->V)-class-method","html_id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,&block:SplayTreeMap(K,V),K->V)-class-method","name":"new","doc":"Creates a new empty `SplayTreeMap` with a *block* that is called when a key is\nmissing from the tree.\n\n```\nstm = SplayTreeMap(String, Array(Int32)).new { |t, k| t[k] = [] of Int32 }\nstm[\"a\"] << 1\nstm[\"a\"] << 2\nstm[\"a\"] << 3\nputs stm.inspect # => [1,2,3]\n```","summary":"

Creates a new empty SplayTreeMap with a block that is called when a key is missing from the tree.

","abstract":false,"args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"}],"args_string":"(seed : Enumerable(Tuple(K, V))? | Iterable(Tuple(K, V))? = nil, &block : SplayTreeMap(K, V), K -> V)","source_link":null,"def":{"name":"new","args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(SplayTreeMap(K, V), K -> V)"},"return_type":"","visibility":"Public","body":"new(seed: seed, block: block)"}},{"id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?,default_value:V)-class-method","html_id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?,default_value:V)-class-method","name":"new","doc":"Creates a new `SplayTreeMap`, populating it with values from the *Enumerable*\nor the *Iterable* seed object, and with a default return value for any missing\nkey.\n\n```\nstm = SplayTreeMap.new({\"this\" => \"that\", \"something\" => \"else\"}, \"Unknown\")\nstm[\"something\"] # => \"else\"\nstm[\"xyzzy\"] # => \"Unknown\"\n```","summary":"

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.

","abstract":false,"args":[{"name":"seed","doc":null,"default_value":"","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"args_string":"(seed : Enumerable(Tuple(K, V))? | Iterable(Tuple(K, V))?, default_value : V)","source_link":null,"def":{"name":"new","args":[{"name":"seed","doc":null,"default_value":"","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new(seed: seed) do\n default_value\nend"}},{"id":"new(default_value:V)-class-method","html_id":"new(default_value:V)-class-method","name":"new","doc":"Creates a new empty `SplayTreeMap` with a default return value for any missing key.\n\n```\nstm = SplayTreeMap(String, String).new(\"Unknown\")\nstm[\"xyzzy\"] # => \"Unknown\"\n```","summary":"

Creates a new empty SplayTreeMap with a default return value for any missing key.

","abstract":false,"args":[{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"args_string":"(default_value : V)","source_link":null,"def":{"name":"new","args":[{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new do\n default_value\nend"}}],"instance_methods":[{"id":"(other:SplayTreeMap(L,W))forallL,W-instance-method","html_id":"(other:SplayTreeMap(L,W))forallL,W-instance-method","name":"<=>","doc":"Compares two SplayTreeMaps. All contained objects must also be comparable,\nor this method will trigger an exception.","summary":"

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.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"clear","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@root = nil\n@size = 0\n@header = Node(K, V).new(nil, nil)\n"}},{"id":"compact-instance-method","html_id":"compact-instance-method","name":"compact","doc":"Returns new `SplayTreeMap` that has all of the `nil` values and their\nassociated keys removed.\n\n```\nstm = SplayTreeMap.new({\"hello\" => \"world\", \"foo\" => nil})\nstm.compact # => {\"hello\" => \"world\"}\n```","summary":"

Returns new SplayTreeMap that has all of the nil values and their associated keys removed.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"compact","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each_with_object(self.class.new) do |__arg0, memo|\n key = __arg0[0]\n value = __arg0[1]\n if value.nil?\n else\n memo[key] = value\n end\nend"}},{"id":"compact!-instance-method","html_id":"compact!-instance-method","name":"compact!","doc":"Removes all `nil` values from `self`. Returns `nil` if no changes were made.\n\n```\nstm = SplayTreeMap.new({\"hello\" => \"world\", \"foo\" => nil})\nstm.compact! # => {\"hello\" => \"world\"}\nstm.compact! # => nil\n```","summary":"

Removes all nil values from self.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"compact!","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reject! do |key, value|\n value.nil?\nend"}},{"id":"delete(key,&)-instance-method","html_id":"delete(key,&)-instance-method","name":"delete","doc":"Deletes the key-value pair and returns the value, else yields *key* with given block.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.delete(\"foo\") { |key| \"#{key} not found\" } # => \"bar\"\nstm.fetch(\"foo\", nil) # => nil\nstm.delete(\"baz\") { |key| \"#{key} not found\" } # => \"baz not found\"\n```","summary":"

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.

","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":null,"block_arg":null,"return_type":"","visibility":"Public","body":"delete(key) do\n nil\nend"}},{"id":"delete_if(&):self-instance-method","html_id":"delete_if(&):self-instance-method","name":"delete_if","doc":"DEPRECATED: This is just `reject!` by another name. Use that instead.\nDeletes each key-value pair for which the given block returns `true`.\nReturns the `SplayTreeMap`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"fob\" => \"baz\", \"bar\" => \"qux\"})\nstm.delete_if { |key, value| key.starts_with?(\"fo\") }\nstm # => { \"bar\" => \"qux\" }\n```","summary":"

DEPRECATED This is just #reject! by another name.

","abstract":false,"args":[],"args_string":"(&) : self","source_link":null,"def":{"name":"delete_if","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"self","visibility":"Public","body":"reject! do |k, v|\n yield k, v\nend\nself\n"}},{"id":"dig(key:K,*subkeys)-instance-method","html_id":"dig(key:K,*subkeys)-instance-method","name":"dig","doc":"Traverses the depth of a structure and returns the value, otherwise\nraises `KeyError`.\n\n```\nh = {\"a\" => {\"b\" => [10, 20, 30]}}\nstm = SplayTreeMap.new(h)\nstm.dig \"a\", \"b\" # => [10, 20, 30]\nstm.dig \"a\", \"c\" # raises KeyError\n```","summary":"

Traverses the depth of a structure and returns the value, otherwise raises KeyError.

","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 return value.dig(*subkeys)\nend\nraise(KeyError.new(\"SplayTreeMap value not diggable for key: #{key.inspect}\"))\n"}},{"id":"dig?(key:K,*subkeys)-instance-method","html_id":"dig?(key:K,*subkeys)-instance-method","name":"dig?","doc":"Traverses the depth of a structure and returns the value.\nReturns `nil` if not found.\n\n```\nh = {\"a\" => {\"b\" => [10, 20, 30]}}\nstm = SplayTreeMap.new(h)\nstm.dig \"a\", \"b\" # => [10, 20, 30]\nstm.dig \"a\", \"c\" # => nil\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"dup","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap.new(self)"}},{"id":"each(&:Tuple(K,V)->):Nil-instance-method","html_id":"each(&:Tuple(K,V)->):Nil-instance-method","name":"each","doc":"Calls the given block for each key/value pair, passing the pair into the block.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\n\nstm.each do |key, value|\n key # => \"foo\"\n value # => \"bar\"\nend\n\nstm.each do |key_and_value|\n key_and_value # => {\"foo\", \"bar\"}\nend\n```\n\nThe enumeration follows the order the keys were inserted.","summary":"

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.

","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":null,"block_arg":null,"return_type":"","visibility":"Public","body":"key_for(value) do\n raise(KeyError.new(\"Missing key for value: #{value}\"))\nend"}},{"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 yields *value* with the given block.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.key_for(\"bar\") { |value| value.upcase } # => \"foo\"\nstm.key_for(\"qux\") { |value| value.upcase } # => \"QUX\"\n```","summary":"

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.

","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":null,"block_arg":null,"return_type":"","visibility":"Public","body":"key_for(value) do\n nil\nend"}},{"id":"keys:Array(K)-instance-method","html_id":"keys:Array(K)-instance-method","name":"keys","doc":"Returns an array of all keys in the tree.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nstm.keys.should eq [\"baz\", \"foo\"]\n```\n","summary":"

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.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L, W))"}],"args_string":"(other : Enumerable(Tuple(L, 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":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(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":3,"block_arg":null,"return_type":"","visibility":"Public","body":"other.each do |k|\n if self.has_key?(k)\n self[k] = yield k, self[k], k\n else\n self[k] = k\n end\nend\nself\n"}},{"id":"merge!(other:Enumerable(Tuple),&)-instance-method","html_id":"merge!(other:Enumerable(Tuple),&)-instance-method","name":"merge!","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(Tuple)"}],"args_string":"(other : Enumerable(Tuple), &)","source_link":null,"def":{"name":"merge!","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(Tuple)"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":null,"return_type":"","visibility":"Public","body":"other.each do |*args|\n if args[0].size == 1\n k = v = args[0][0]\n else\n k = args[0][0]\n v = args[0][-1]\n end\n if self.has_key?(k)\n self[k] = yield k, self[k], v\n else\n self[k] = v\n end\nend\nself\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":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)), &) 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":null,"return_type":"","visibility":"Public","body":"other.each do |k, v|\n if self.has_key?(k)\n self[k] = yield k, self[k], v\n else\n self[k] = v\n end\nend\nself\n"}},{"id":"merge!(other:T)forallT-instance-method","html_id":"merge!(other:T)forallT-instance-method","name":"merge!","doc":"Adds the contents of *other* to this `SplayTreeMap`.\n\nFor Array-like structures, which return a single value to the block passed\nto `#each`, that value will be used for both the key and the value.\n\nFor Array-like structures, where each array element is a two value Tuple,\nthe first value of the Tuple will be the key, and the second will be the\nvalue.\n\nFor Hash-like structures, which pass a key/value tuple into the `#each`,\nthe key and value will be used for the key and value in the tree entry.\n\nIf a Tuple is passed into the `#each` that has more or fewer than 2 elements,\nthe key for the tree entry will come from the first element in the Tuple, and\nthe value will come from the last element in the Tuple.\n\n```\na = [] of Int32\n10.times {|x| a << x}\nstm = SplayTreeMap(Int32, Int32).new({6 => 0, 11 => 0}).merge!(a)\nstm[11] # => 0\nstm[6] # => 6\n\nh = {} of Int32 => Int32\n10.times {|x| h[x] = x**2}\nstm = SplayTreeMap(Int32, Int32).new.merge!(h)\nstm[6] # => 36\n\nstm = SplayTreeMap(Int32, Int32).new.merge!({ {4,16},{5},{7,49,343} })\nstm[4] # => 16\nstm[5] # => 5\nstm[7] # => 343\n","summary":"

Adds the contents of other to this SplayTreeMap.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"T"}],"args_string":"(other : T) forall T","source_link":null,"def":{"name":"merge!","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"T"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self.merge!(other) do |k, v1, v2|\n v2\nend"}},{"id":"min-instance-method","html_id":"min-instance-method","name":"min","doc":"Returns the smallest key in the tree.","summary":"

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.

","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":"reject(keys:Array|Tuple)-instance-method","html_id":"reject(keys:Array|Tuple)-instance-method","name":"reject","doc":"Removes a list of keys out of the tree, returning a new tree.\n\n```\nh = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject(\"a\", \"c\")\nh # => {\"b\" => 2, \"d\" => 4}\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"reject","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K, V).new) do |__arg1, memo|\n k = __arg1[0]\n v = __arg1[1]\n if yield k, v\n else\n memo[k] = v\n end\nend"}},{"id":"reject!(&block:K,V->_)-instance-method","html_id":"reject!(&block:K,V->_)-instance-method","name":"reject!","doc":"Equivalent to `SplayTreeMap#reject`, but modifies the current object rather than\nreturning a new one. Returns `nil` if no changes were made.","summary":"

Equivalent to SplayTreeMap#reject, but modifies the current object rather than returning a new one.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"reject!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"num_entries = size\nkeys_to_delete = [] of K\neach do |key, value|\n if yield key, value\n keys_to_delete << key\n end\nend\nkeys_to_delete.each do |key|\n delete(key)\nend\nnum_entries == size ? nil : self\n"}},{"id":"reject!(keys:Array|Tuple)-instance-method","html_id":"reject!(keys:Array|Tuple)-instance-method","name":"reject!","doc":"Removes a list of keys out of the tree.\n\n```\nh = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject!(\"a\", \"c\")\nh # => {\"b\" => 2, \"d\" => 4}\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"select","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"reject do |k, v|\n !(yield k, v)\nend"}},{"id":"select(keys:Array|Tuple)-instance-method","html_id":"select(keys:Array|Tuple)-instance-method","name":"select","doc":"Returns a new `SplayTreeMap` with the given keys.\n\n```\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select({\"a\", \"c\"}) # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select(\"a\", \"c\") # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select([\"a\", \"c\"]) # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

Returns a new SplayTreeMap with the given keys.

","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":"stm = SplayTreeMap(K, V).new\nkeys.each do |k|\n k = k.as(K)\n if has_key?(k)\n stm[k] = obtain(k)\n end\nend\nstm\n"}},{"id":"select(*keys)-instance-method","html_id":"select(*keys)-instance-method","name":"select","doc":"Returns a new `SplayTreeMap` with the given keys.\n\n```\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select({\"a\", \"c\"}) # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select(\"a\", \"c\") # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select([\"a\", \"c\"]) # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

Returns a new SplayTreeMap with the given keys.

","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":"self.select(keys)"}},{"id":"select!(*keys)-instance-method","html_id":"select!(*keys)-instance-method","name":"select!","doc":"Removes every element except the given ones.\n\n```\nh1 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!({\"a\", \"c\"})\nh2 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!(\"a\", \"c\")\nh3 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!([\"a\", \"c\"])\nh1 == h2 == h3 # => true\nh1 # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"select!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"reject! do |k, v|\n !(yield k, v)\nend"}},{"id":"select!(keys:Array|Tuple)-instance-method","html_id":"select!(keys:Array|Tuple)-instance-method","name":"select!","doc":"Removes every element except the given ones.\n\n```\nh1 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!({\"a\", \"c\"})\nh2 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!(\"a\", \"c\")\nh3 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!([\"a\", \"c\"])\nh1 == h2 == h3 # => true\nh1 # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

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)).

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"to_a","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"a = Array(::Tuple(K, V)).new\neach do |k, v|\n a << {k, v}\nend\na\n"}},{"id":"to_h-instance-method","html_id":"to_h-instance-method","name":"to_h","doc":"Transform a `SplayTreeMap(K,V)` into a `Hash(K,V)`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nh = stm.to_h # => {\"baz\" => \"qux\", \"foo\" => \"bar\"}\n```","summary":"

Transform a SplayTreeMap(K,V) into a Hash(K,V).

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"to_h","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"h = Hash(K, V).new\neach do |k, v|\n h[k] = v\nend\nh\n"}},{"id":"to_s(io:IO):Nil-instance-method","html_id":"to_s(io:IO):Nil-instance-method","name":"to_s","doc":"Transform the `SplayTreeMap` into a `String` representation.","summary":"

Transform the SplayTreeMap into a String representation.

","abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : Nil","source_link":null,"def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":"IO"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"final = self.size\ncount = 0\nio << String.build do |buff|\n buff << \"{ \"\n self.each do |k, v|\n count = count + 1\n buff << k.inspect\n buff << \" => \"\n buff << v.inspect\n if count < final\n buff << \", \"\n end\n end\n buff << \" }\"\nend\n"}},{"id":"transform(&block:Tuple(K,V)->Tuple(K2,V2))forallK2,V2-instance-method","html_id":"transform(&block:Tuple(K,V)->Tuple(K2,V2))forallK2,V2-instance-method","name":"transform","doc":"Returns a new `SplayTreeMap` with all of the key/value pairs converted using\nthe provided block. The block can change the types of both keys and values.\n\n```\nstm = SplayTreeMap({1 => 1, 2 => 4, 3 => 9, 4 => 16})\nstm = stm.transform {|k, v| {k.to_s, v.to_s}}\nstm # => {\"1\" => \"1\", \"2\" => \"4\", \"3\" => \"9\", \"4\" => \"16\"}\n```\n","summary":"

Returns a new SplayTreeMap with all of the key/value pairs converted using the provided block.

","abstract":false,"args":[],"args_string":"(&block : Tuple(K, V) -> Tuple(K2, V2)) forall K2, V2","source_link":null,"def":{"name":"transform","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(::Tuple(K, V) -> ::Tuple(K2, V2))"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K2, V2).new) do |__arg2, memo|\n key = __arg2[0]\n value = __arg2[1]\n key2, value2 = yield {key, value}\n memo[key2] = value2\nend"}},{"id":"transform_keys(&block:K->K2)forallK2-instance-method","html_id":"transform_keys(&block:K->K2)forallK2-instance-method","name":"transform_keys","doc":"Returns a new `SplayTreeMap` with all keys converted using the block operation.\nThe block can change a type of keys.\n\n```\nstm = SplayTreeMap.new({:a => 1, :b => 2, :c => 3})\nstm.transform_keys { |key| key.to_s } # => {\"a\" => 1, \"b\" => 2, \"c\" => 3}\n```","summary":"

Returns a new SplayTreeMap with all keys converted using the block operation.

","abstract":false,"args":[],"args_string":"(&block : K -> K2) forall K2","source_link":null,"def":{"name":"transform_keys","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K -> K2)"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K2, V).new) do |__arg3, memo|\n key = __arg3[0]\n value = __arg3[1]\n memo[yield key] = value\nend"}},{"id":"transform_values(&block:V->V2)forallV2-instance-method","html_id":"transform_values(&block:V->V2)forallV2-instance-method","name":"transform_values","doc":"Returns a new SplayTreeMap with all values converted using the block operation.\nThe block can change a type of values.\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":"

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.

","abstract":false,"args":[],"args_string":"(&block : V -> V)","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 -> V)"},"return_type":"","visibility":"Public","body":"each do |key, value|\n memo[key] = yield value\nend\nself\n"}},{"id":"values:Array(V)-instance-method","html_id":"values:Array(V)-instance-method","name":"values","doc":"Returns an array containing all of the values in the tree. The array is in\nthe order of the associated keys.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4})\nstm.values # => [1, 2, 3, 4]\n```\n","summary":"

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

","class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[]}]}}) \ No newline at end of file +crystal_doc_search_index_callback({"repository_name":"Splay Tree Map","body":"# Splay Tree Map\n\n[![GitHub release](https://img.shields.io/github/release/wyhaines/splay_tree_map.cr.svg)](https://github.com/wyhaines/splay_tree_map.cr/releases)\n\nA splay tree is a type of binary search tree that self organizes so that the\nmost frequently accessed items tend to be towards the root of the tree, where\nthey can be accessed more quickly.\n\nThis implementation provides a hash-like interface, and it provides a couple\nfeatures not typically found in Splay Trees -- efficient removal of the items\nthat are generally least frequently accessed, and an extra fast search option.\n\n### Leaf Pruning\n\nBecause splay trees tend to organize themselves with the most frequently\naccessed elements towards the root of the tree, the least frequently accessed\nitems tend to migrate towards the leaves of the tree. This implementation\noffers a method that can be used to prune its leaves, which generally has the\neffect of removing the least frequently accessed items from the tree.\n\nThis is useful if the data structure is being used to implement a cache, as\nit can be used to control the size of the cache while generaly keeping the\nmost useful items in the cache without any other extensive bookkeeping.\n\n### Search without Splaying\n\nA splay operation is generally performed on any access to a splay tree. This is\nthe operation that moves the most important items towards the root. This operation\nhas a cost to it, however, and there are times when it is desireable to search the\nhash without a splay operation occuring for the key that is searched. This results\nin a faster search operation, at the cost of not performing any efficiency improving\nstructural changes to the tree. This should not be the primary search method that\nis used, but it can be useful at the right time.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n stm:\n github: wyhaines/splay_tree_map.cr\n ```\n\n2. Run `shards install`\n\n## Usage\n\nFull documentation can be found at: [https://wyhaines.github.io/splay_tree_map.cr/index.html](https://wyhaines.github.io/splay_tree_map.cr/index.html)\n\n```crystal\nrequire \"splay_tree_map\"\n```\n\nGenerally, the data structure is used like a hash.\n\n```crystal\nstm = SplayTreeMap(String, String).new\n\nstm[\"this\"] = \"that\"\nstm[\"something\"] = \"else\"\nstm[\"junk\"] = \"pile\"\n\nif stm.has_key?(\"this\")\n puts stm[\"this\"]\nend\n\nstm.delete(\"junk\")\n\nputs stm.obtain(\"something\") # This finds, but doesn't splay.\n\nstm.prune # remove all leaves\n```\n\n## TODO\n\nExperiment with other variations of splay operations, such as lazy semi-splay\nto see if performance can be improved. Right now this isn't any better than\njust using a Hash and arbitrarily deleting half of the hash if it grows too big.\n\n## Credits\n\nThis implementation is derived from the incomplete and broken implementation\nin the Crystalline shard found at https://github.com/jtomschroeder/crystalline\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Kirk Haines](https://github.com/wyhaines) - creator and maintainer\n","program":{"html_id":"Splay Tree Map/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"Splay Tree Map","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"Splay Tree Map/SplayTreeMap","path":"SplayTreeMap.html","kind":"class","full_name":"SplayTreeMap(K, V)","name":"SplayTreeMap","abstract":false,"superclass":{"html_id":"Splay Tree Map/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"Splay Tree Map/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Splay Tree Map/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"Splay Tree Map/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"Splay Tree Map/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"Splay Tree Map/Object","kind":"class","full_name":"Object","name":"Object"}],"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":[{"html_id":"Splay Tree Map/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"Splay Tree Map/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"Splay Tree Map/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[{"id":"zip(ary1:Array(K),ary2:Array(V))-class-method","html_id":"zip(ary1:Array(K),ary2:Array(V))-class-method","name":"zip","doc":"Zips two arrays into a `SplayTreeMap`, taking keys from *ary1* and values from *ary2*.\n\n```\nSplayTreeMap.zip([\"key1\", \"key2\", \"key3\"], [\"value1\", \"value2\", \"value3\"])\n# => {\"key1\" => \"value1\", \"key2\" => \"value2\", \"key3\" => \"value3\"}\n```","summary":"

Zips two arrays into a SplayTreeMap, taking keys from ary1 and values from ary2.

","abstract":false,"args":[{"name":"ary1","doc":null,"default_value":"","external_name":"ary1","restriction":"Array(K)"},{"name":"ary2","doc":null,"default_value":"","external_name":"ary2","restriction":"Array(V)"}],"args_string":"(ary1 : Array(K), ary2 : Array(V))","source_link":null,"def":{"name":"zip","args":[{"name":"ary1","doc":null,"default_value":"","external_name":"ary1","restriction":"Array(K)"},{"name":"ary2","doc":null,"default_value":"","external_name":"ary2","restriction":"Array(V)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap(K, V).new\nary1.each_with_index do |key, i|\n stm[key] = ary2[i]\nend\nstm\n"}}],"constructors":[{"id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,block:SplayTreeMap(K,V),K->V?=nil)-class-method","html_id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,block:SplayTreeMap(K,V),K->V?=nil)-class-method","name":"new","doc":"Creates a new empty `SplayTreeMap` with a *block* that is called when a key is\nmissing from the tree.\n\n```\nstm = SplayTreeMap(String, Array(Int32)).new { |t, k| t[k] = [] of Int32 }\nstm[\"a\"] << 1\nstm[\"a\"] << 2\nstm[\"a\"] << 3\nputs stm.inspect # => [1,2,3]\n```","summary":"

Creates a new empty SplayTreeMap with a block that is called when a key is missing from the tree.

","abstract":false,"args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"block","doc":null,"default_value":"nil","external_name":"block","restriction":"(SplayTreeMap(K, V), K -> V) | ::Nil"}],"args_string":"(seed : Enumerable(Tuple(K, V))? | Iterable(Tuple(K, V))? = nil, block : SplayTreeMap(K, V), K -> V? = nil)","source_link":null,"def":{"name":"new","args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"block","doc":null,"default_value":"nil","external_name":"block","restriction":"(SplayTreeMap(K, V), K -> V) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = SplayTreeMap(K, V).allocate\n_.initialize(seed, block)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,&block:SplayTreeMap(K,V),K->V)-class-method","html_id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?=nil,&block:SplayTreeMap(K,V),K->V)-class-method","name":"new","doc":"Creates a new empty `SplayTreeMap` with a *block* that is called when a key is\nmissing from the tree.\n\n```\nstm = SplayTreeMap(String, Array(Int32)).new { |t, k| t[k] = [] of Int32 }\nstm[\"a\"] << 1\nstm[\"a\"] << 2\nstm[\"a\"] << 3\nputs stm.inspect # => [1,2,3]\n```","summary":"

Creates a new empty SplayTreeMap with a block that is called when a key is missing from the tree.

","abstract":false,"args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"}],"args_string":"(seed : Enumerable(Tuple(K, V))? | Iterable(Tuple(K, V))? = nil, &block : SplayTreeMap(K, V), K -> V)","source_link":null,"def":{"name":"new","args":[{"name":"seed","doc":null,"default_value":"nil","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(SplayTreeMap(K, V), K -> V)"},"return_type":"","visibility":"Public","body":"new(seed: seed, block: block)"}},{"id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?,default_value:V)-class-method","html_id":"new(seed:Enumerable(Tuple(K,V))?|Iterable(Tuple(K,V))?,default_value:V)-class-method","name":"new","doc":"Creates a new `SplayTreeMap`, populating it with values from the *Enumerable*\nor the *Iterable* seed object, and with a default return value for any missing\nkey.\n\n```\nstm = SplayTreeMap.new({\"this\" => \"that\", \"something\" => \"else\"}, \"Unknown\")\nstm[\"something\"] # => \"else\"\nstm[\"xyzzy\"] # => \"Unknown\"\n```","summary":"

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.

","abstract":false,"args":[{"name":"seed","doc":null,"default_value":"","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"args_string":"(seed : Enumerable(Tuple(K, V))? | Iterable(Tuple(K, V))?, default_value : V)","source_link":null,"def":{"name":"new","args":[{"name":"seed","doc":null,"default_value":"","external_name":"seed","restriction":"Enumerable(::Tuple(K, V)) | ::Nil | Iterable(::Tuple(K, V)) | ::Nil"},{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new(seed: seed) do\n default_value\nend"}},{"id":"new(default_value:V)-class-method","html_id":"new(default_value:V)-class-method","name":"new","doc":"Creates a new empty `SplayTreeMap` with a default return value for any missing key.\n\n```\nstm = SplayTreeMap(String, String).new(\"Unknown\")\nstm[\"xyzzy\"] # => \"Unknown\"\n```","summary":"

Creates a new empty SplayTreeMap with a default return value for any missing key.

","abstract":false,"args":[{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"args_string":"(default_value : V)","source_link":null,"def":{"name":"new","args":[{"name":"default_value","doc":null,"default_value":"","external_name":"default_value","restriction":"V"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new do\n default_value\nend"}}],"instance_methods":[{"id":"(other:SplayTreeMap(L,W))forallL,W-instance-method","html_id":"(other:SplayTreeMap(L,W))forallL,W-instance-method","name":"<=>","doc":"Compares two SplayTreeMaps. All contained objects must also be comparable,\nor this method will trigger an exception.","summary":"

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.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"clear","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@root = nil\n@size = 0\n@header = Node(K, V).new(nil, nil)\n"}},{"id":"compact-instance-method","html_id":"compact-instance-method","name":"compact","doc":"Returns new `SplayTreeMap` that has all of the `nil` values and their\nassociated keys removed.\n\n```\nstm = SplayTreeMap.new({\"hello\" => \"world\", \"foo\" => nil})\nstm.compact # => {\"hello\" => \"world\"}\n```","summary":"

Returns new SplayTreeMap that has all of the nil values and their associated keys removed.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"compact","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each_with_object(self.class.new) do |__arg0, memo|\n key = __arg0[0]\n value = __arg0[1]\n if value.nil?\n else\n memo[key] = value\n end\nend"}},{"id":"compact!-instance-method","html_id":"compact!-instance-method","name":"compact!","doc":"Removes all `nil` values from `self`. Returns `nil` if no changes were made.\n\n```\nstm = SplayTreeMap.new({\"hello\" => \"world\", \"foo\" => nil})\nstm.compact! # => {\"hello\" => \"world\"}\nstm.compact! # => nil\n```","summary":"

Removes all nil values from self.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"compact!","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reject! do |key, value|\n value.nil?\nend"}},{"id":"delete(key,&)-instance-method","html_id":"delete(key,&)-instance-method","name":"delete","doc":"Deletes the key-value pair and returns the value, else yields *key* with given block.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.delete(\"foo\") { |key| \"#{key} not found\" } # => \"bar\"\nstm.fetch(\"foo\", nil) # => nil\nstm.delete(\"baz\") { |key| \"#{key} not found\" } # => \"baz not found\"\n```","summary":"

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.

","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":null,"block_arg":null,"return_type":"","visibility":"Public","body":"delete(key) do\n nil\nend"}},{"id":"delete_if(&):self-instance-method","html_id":"delete_if(&):self-instance-method","name":"delete_if","doc":"DEPRECATED: This is just `reject!` by another name. Use that instead.\nDeletes each key-value pair for which the given block returns `true`.\nReturns the `SplayTreeMap`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"fob\" => \"baz\", \"bar\" => \"qux\"})\nstm.delete_if { |key, value| key.starts_with?(\"fo\") }\nstm # => { \"bar\" => \"qux\" }\n```","summary":"

DEPRECATED This is just #reject! by another name.

","abstract":false,"args":[],"args_string":"(&) : self","source_link":null,"def":{"name":"delete_if","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"self","visibility":"Public","body":"reject! do |k, v|\n yield k, v\nend\nself\n"}},{"id":"dig(key:K,*subkeys)-instance-method","html_id":"dig(key:K,*subkeys)-instance-method","name":"dig","doc":"Traverses the depth of a structure and returns the value, otherwise\nraises `KeyError`.\n\n```\nh = {\"a\" => {\"b\" => [10, 20, 30]}}\nstm = SplayTreeMap.new(h)\nstm.dig \"a\", \"b\" # => [10, 20, 30]\nstm.dig \"a\", \"c\" # raises KeyError\n```","summary":"

Traverses the depth of a structure and returns the value, otherwise raises KeyError.

","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 return value.dig(*subkeys)\nend\nraise(KeyError.new(\"SplayTreeMap value not diggable for key: #{key.inspect}\"))\n"}},{"id":"dig?(key:K,*subkeys)-instance-method","html_id":"dig?(key:K,*subkeys)-instance-method","name":"dig?","doc":"Traverses the depth of a structure and returns the value.\nReturns `nil` if not found.\n\n```\nh = {\"a\" => {\"b\" => [10, 20, 30]}}\nstm = SplayTreeMap.new(h)\nstm.dig \"a\", \"b\" # => [10, 20, 30]\nstm.dig \"a\", \"c\" # => nil\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"dup","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"stm = SplayTreeMap.new(self)"}},{"id":"each(&:Tuple(K,V)->):Nil-instance-method","html_id":"each(&:Tuple(K,V)->):Nil-instance-method","name":"each","doc":"Calls the given block for each key/value pair, passing the pair into the block.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\n\nstm.each do |key, value|\n key # => \"foo\"\n value # => \"bar\"\nend\n\nstm.each do |key_and_value|\n key_and_value # => {\"foo\", \"bar\"}\nend\n```\n\nThe enumeration follows the order the keys were inserted.","summary":"

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.

","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":null,"block_arg":null,"return_type":"","visibility":"Public","body":"key_for(value) do\n raise(KeyError.new(\"Missing key for value: #{value}\"))\nend"}},{"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 yields *value* with the given block.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\"})\nstm.key_for(\"bar\") { |value| value.upcase } # => \"foo\"\nstm.key_for(\"qux\") { |value| value.upcase } # => \"QUX\"\n```","summary":"

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.

","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":null,"block_arg":null,"return_type":"","visibility":"Public","body":"key_for(value) do\n nil\nend"}},{"id":"keys:Array(K)-instance-method","html_id":"keys:Array(K)-instance-method","name":"keys","doc":"Returns an array of all keys in the tree.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nstm.keys.should eq [\"baz\", \"foo\"]\n```\n","summary":"

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.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(::Tuple(L, W))"}],"args_string":"(other : Enumerable(Tuple(L, 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":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(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":3,"block_arg":null,"return_type":"","visibility":"Public","body":"other.each do |k|\n if self.has_key?(k)\n self[k] = yield k, self[k], k\n else\n self[k] = k\n end\nend\nself\n"}},{"id":"merge!(other:Enumerable(Tuple),&)-instance-method","html_id":"merge!(other:Enumerable(Tuple),&)-instance-method","name":"merge!","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(Tuple)"}],"args_string":"(other : Enumerable(Tuple), &)","source_link":null,"def":{"name":"merge!","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Enumerable(Tuple)"}],"double_splat":null,"splat_index":null,"yields":3,"block_arg":null,"return_type":"","visibility":"Public","body":"other.each do |*args|\n if args[0].size == 1\n k = v = args[0][0]\n else\n k = args[0][0]\n v = args[0][-1]\n end\n if self.has_key?(k)\n self[k] = yield k, self[k], v\n else\n self[k] = v\n end\nend\nself\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":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)), &) 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":null,"return_type":"","visibility":"Public","body":"other.each do |k, v|\n if self.has_key?(k)\n self[k] = yield k, self[k], v\n else\n self[k] = v\n end\nend\nself\n"}},{"id":"merge!(other:T)forallT-instance-method","html_id":"merge!(other:T)forallT-instance-method","name":"merge!","doc":"Adds the contents of *other* to this `SplayTreeMap`.\n\nFor Array-like structures, which return a single value to the block passed\nto `#each`, that value will be used for both the key and the value.\n\nFor Array-like structures, where each array element is a two value Tuple,\nthe first value of the Tuple will be the key, and the second will be the\nvalue.\n\nFor Hash-like structures, which pass a key/value tuple into the `#each`,\nthe key and value will be used for the key and value in the tree entry.\n\nIf a Tuple is passed into the `#each` that has more or fewer than 2 elements,\nthe key for the tree entry will come from the first element in the Tuple, and\nthe value will come from the last element in the Tuple.\n\n```\na = [] of Int32\n10.times {|x| a << x}\nstm = SplayTreeMap(Int32, Int32).new({6 => 0, 11 => 0}).merge!(a)\nstm[11] # => 0\nstm[6] # => 6\n\nh = {} of Int32 => Int32\n10.times {|x| h[x] = x**2}\nstm = SplayTreeMap(Int32, Int32).new.merge!(h)\nstm[6] # => 36\n\nstm = SplayTreeMap(Int32, Int32).new.merge!({ {4,16},{5},{7,49,343} })\nstm[4] # => 16\nstm[5] # => 5\nstm[7] # => 343\n","summary":"

Adds the contents of other to this SplayTreeMap.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"T"}],"args_string":"(other : T) forall T","source_link":null,"def":{"name":"merge!","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"T"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self.merge!(other) do |k, v1, v2|\n v2\nend"}},{"id":"min-instance-method","html_id":"min-instance-method","name":"min","doc":"Returns the smallest key in the tree.","summary":"

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.

","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":"reject(keys:Array|Tuple)-instance-method","html_id":"reject(keys:Array|Tuple)-instance-method","name":"reject","doc":"Removes a list of keys out of the tree, returning a new tree.\n\n```\nh = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject(\"a\", \"c\")\nh # => {\"b\" => 2, \"d\" => 4}\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"reject","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K, V).new) do |__arg1, memo|\n k = __arg1[0]\n v = __arg1[1]\n if yield k, v\n else\n memo[k] = v\n end\nend"}},{"id":"reject!(&block:K,V->_)-instance-method","html_id":"reject!(&block:K,V->_)-instance-method","name":"reject!","doc":"Equivalent to `SplayTreeMap#reject`, but modifies the current object rather than\nreturning a new one. Returns `nil` if no changes were made.","summary":"

Equivalent to SplayTreeMap#reject, but modifies the current object rather than returning a new one.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"reject!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"num_entries = size\nkeys_to_delete = [] of K\neach do |key, value|\n if yield key, value\n keys_to_delete << key\n end\nend\nkeys_to_delete.each do |key|\n delete(key)\nend\nnum_entries == size ? nil : self\n"}},{"id":"reject!(keys:Array|Tuple)-instance-method","html_id":"reject!(keys:Array|Tuple)-instance-method","name":"reject!","doc":"Removes a list of keys out of the tree.\n\n```\nh = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.reject!(\"a\", \"c\")\nh # => {\"b\" => 2, \"d\" => 4}\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"select","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"reject do |k, v|\n !(yield k, v)\nend"}},{"id":"select(keys:Array|Tuple)-instance-method","html_id":"select(keys:Array|Tuple)-instance-method","name":"select","doc":"Returns a new `SplayTreeMap` with the given keys.\n\n```\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select({\"a\", \"c\"}) # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select(\"a\", \"c\") # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select([\"a\", \"c\"]) # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

Returns a new SplayTreeMap with the given keys.

","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":"stm = SplayTreeMap(K, V).new\nkeys.each do |k|\n k = k.as(K)\n if has_key?(k)\n stm[k] = obtain(k)\n end\nend\nstm\n"}},{"id":"select(*keys)-instance-method","html_id":"select(*keys)-instance-method","name":"select","doc":"Returns a new `SplayTreeMap` with the given keys.\n\n```\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select({\"a\", \"c\"}) # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select(\"a\", \"c\") # => {\"a\" => 1, \"c\" => 3}\nSplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}).select([\"a\", \"c\"]) # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

Returns a new SplayTreeMap with the given keys.

","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":"self.select(keys)"}},{"id":"select!(*keys)-instance-method","html_id":"select!(*keys)-instance-method","name":"select!","doc":"Removes every element except the given ones.\n\n```\nh1 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!({\"a\", \"c\"})\nh2 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!(\"a\", \"c\")\nh3 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!([\"a\", \"c\"])\nh1 == h2 == h3 # => true\nh1 # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

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.

","abstract":false,"args":[],"args_string":"(&block : K, V -> _)","source_link":null,"def":{"name":"select!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K, V -> _)"},"return_type":"","visibility":"Public","body":"reject! do |k, v|\n !(yield k, v)\nend"}},{"id":"select!(keys:Array|Tuple)-instance-method","html_id":"select!(keys:Array|Tuple)-instance-method","name":"select!","doc":"Removes every element except the given ones.\n\n```\nh1 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!({\"a\", \"c\"})\nh2 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!(\"a\", \"c\")\nh3 = {\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4}.select!([\"a\", \"c\"])\nh1 == h2 == h3 # => true\nh1 # => {\"a\" => 1, \"c\" => 3}\n```","summary":"

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)).

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"to_a","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"a = Array(::Tuple(K, V)).new\neach do |k, v|\n a << {k, v}\nend\na\n"}},{"id":"to_h-instance-method","html_id":"to_h-instance-method","name":"to_h","doc":"Transform a `SplayTreeMap(K,V)` into a `Hash(K,V)`.\n\n```\nstm = SplayTreeMap.new({\"foo\" => \"bar\", \"baz\" => \"qux\"})\nh = stm.to_h # => {\"baz\" => \"qux\", \"foo\" => \"bar\"}\n```","summary":"

Transform a SplayTreeMap(K,V) into a Hash(K,V).

","abstract":false,"args":[],"args_string":"","source_link":null,"def":{"name":"to_h","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"h = Hash(K, V).new\neach do |k, v|\n h[k] = v\nend\nh\n"}},{"id":"to_s(io:IO):Nil-instance-method","html_id":"to_s(io:IO):Nil-instance-method","name":"to_s","doc":"Transform the `SplayTreeMap` into a `String` representation.","summary":"

Transform the SplayTreeMap into a String representation.

","abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":"IO"}],"args_string":"(io : IO) : Nil","source_link":null,"def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":"IO"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"final = self.size\ncount = 0\nio << String.build do |buff|\n buff << \"{ \"\n self.each do |k, v|\n count = count + 1\n buff << k.inspect\n buff << \" => \"\n buff << v.inspect\n if count < final\n buff << \", \"\n end\n end\n buff << \" }\"\nend\n"}},{"id":"transform(&block:Tuple(K,V)->Tuple(K2,V2))forallK2,V2-instance-method","html_id":"transform(&block:Tuple(K,V)->Tuple(K2,V2))forallK2,V2-instance-method","name":"transform","doc":"Returns a new `SplayTreeMap` with all of the key/value pairs converted using\nthe provided block. The block can change the types of both keys and values.\n\n```\nstm = SplayTreeMap({1 => 1, 2 => 4, 3 => 9, 4 => 16})\nstm = stm.transform {|k, v| {k.to_s, v.to_s}}\nstm # => {\"1\" => \"1\", \"2\" => \"4\", \"3\" => \"9\", \"4\" => \"16\"}\n```\n","summary":"

Returns a new SplayTreeMap with all of the key/value pairs converted using the provided block.

","abstract":false,"args":[],"args_string":"(&block : Tuple(K, V) -> Tuple(K2, V2)) forall K2, V2","source_link":null,"def":{"name":"transform","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(::Tuple(K, V) -> ::Tuple(K2, V2))"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K2, V2).new) do |__arg2, memo|\n key = __arg2[0]\n value = __arg2[1]\n key2, value2 = yield {key, value}\n memo[key2] = value2\nend"}},{"id":"transform_keys(&block:K->K2)forallK2-instance-method","html_id":"transform_keys(&block:K->K2)forallK2-instance-method","name":"transform_keys","doc":"Returns a new `SplayTreeMap` with all keys converted using the block operation.\nThe block can change a type of keys.\n\n```\nstm = SplayTreeMap.new({:a => 1, :b => 2, :c => 3})\nstm.transform_keys { |key| key.to_s } # => {\"a\" => 1, \"b\" => 2, \"c\" => 3}\n```","summary":"

Returns a new SplayTreeMap with all keys converted using the block operation.

","abstract":false,"args":[],"args_string":"(&block : K -> K2) forall K2","source_link":null,"def":{"name":"transform_keys","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(K -> K2)"},"return_type":"","visibility":"Public","body":"each_with_object(SplayTreeMap(K2, V).new) do |__arg3, memo|\n key = __arg3[0]\n value = __arg3[1]\n memo[yield key] = value\nend"}},{"id":"transform_values(&block:V->V2)forallV2-instance-method","html_id":"transform_values(&block:V->V2)forallV2-instance-method","name":"transform_values","doc":"Returns a new SplayTreeMap with all values converted using the block operation.\nThe block can change a type of values.\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":"

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.

","abstract":false,"args":[],"args_string":"(&block : V -> V)","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 -> V)"},"return_type":"","visibility":"Public","body":"each do |key, value|\n memo[key] = yield value\nend\nself\n"}},{"id":"values:Array(V)-instance-method","html_id":"values:Array(V)-instance-method","name":"values","doc":"Returns an array containing all of the values in the tree. The array is in\nthe order of the associated keys.\n\n```\nstm = SplayTreeMap.new({\"a\" => 1, \"b\" => 2, \"c\" => 3, \"d\" => 4})\nstm.values # => [1, 2, 3, 4]\n```\n","summary":"

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

","class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[]}]}}) \ No newline at end of file