NgLib::AATreeMap(K, V)
Inherits Enumerable < Reference < Object
順序付き連想配列です。
平衡二分探索木として AA木 を使用しています。 性能は赤黒木の方が良いことが多い気がします。
C++の標準ライブラリの multiset と違って、$k$ 番目の値が取り出せることなどが魅力的です。
Constructors
new(enumerable : Enumerable(Tuple(K, V)))
Sourcenew(default : V)
Sourcenew
SourceInstance methods
<<(item : Tuple(K, V)) : Nil
Source[](key : K) : V
Source[]=(key : K, value : V) : V
Source[]?(key : K) : V | Nil
Sourceclear
Sourceconcat(elems) : self
Sourcedelete_key(key : K) : Bool
Sourceeach_key
Sourceeach_value
Sourceempty?
Returns true if self does not contain any element.
([] of Int32).empty? # => true
([1]).empty? # => false
[nil, false].empty? # => false
#present?returns the inverse.
greater_equal_index(key : K) : Int32 | Nil
Sourcegreater_index(key : K) : Int32 | Nil
Sourcehas_key?(key : K) : Bool
Sourceincludes?(key : K, value : V) : Bool
Sourceinspect(io : IO)
Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>
keys
Sourceless_equal_index(key : K) : Int32 | Nil
Sourceless_index(key : K) : Int32 | Nil
Sourcelower_bound_index(key : K) : Int32
Sourceto_a
Returns an Array with all the elements in the collection.
(1..5).to_a # => [1, 2, 3, 4, 5]
to_s(io : IO) : Nil
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>
upper_bound_index(key : K) : Int32
Sourcevalues
Source