class NgLib::AATreeMultiset(T)
- NgLib::AATreeMultiset(T)
- Reference
- Object
Overview
順序付き多重集合です。
平衡二分探索木として AA木 を使用しています。 性能は赤黒木の方が良いことが多い気がします。
C++の標準ライブラリの multiset
と違って、$k$ 番目の値が取り出せることなどが魅力的です。
Included Modules
- Enumerable(T)
Defined in:
nglib/data_structure/aatree_multiset.crConstructors
Instance Method Summary
- #<<(val : T) : Bool
- #==(other : AATreeSet(T)) : Bool
- #[](k : Int) : T
- #[]?(k : Int) : T | Nil
- #add(val : T) : Nil
- #add?(val : T) : Bool
- #at(k : Int) : T
- #at?(k : Int) : T | Nil
- #clear
- #concat(elems) : self
- #count(val : T) : Int32
- #delete(val : T) : Bool
- #delete_at(k : Int) : Bool
- #delete_at?(k : Int) : Bool
-
#each(& : T -> )
Must yield this collection's elements to the block.
-
#empty? : Bool
Returns
true
ifself
does not contain any element. -
#first : T
Returns the first element in the collection.
-
#first? : T | Nil
Returns the first element in the collection.
- #greater_equal_index(val : T) : Int32 | Nil
- #greater_index(val : T) : Int32 | Nil
- #includes?(val : T) : Bool
-
#inspect(io : IO) : Nil
Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.
- #last : T
- #last? : T | Nil
- #less_equal_index(val : T) : Int32 | Nil
- #less_index(val : T) : Int32 | Nil
- #lower_bound_index(val : T) : Int32
-
#size : Int32
Returns the number of elements in the collection.
-
#to_a : Array(T)
Returns an
Array
with all the elements in the collection. -
#to_s(io : IO) : Nil
Appends a short String representation of this object which includes its class name and its object address.
- #upper_bound_index(val : T) : Int32
Constructor Detail
Instance Method Detail
Must yield this collection's elements to the block.
Returns true
if self
does not contain any element.
([] of Int32).empty? # => true
([1]).empty? # => false
[nil, false].empty? # => false
#present?
returns the inverse.
Returns the first element in the collection. Raises Enumerable::EmptyError
if the collection is empty.
([1, 2, 3]).first # => 1
([] of Int32).first # raises Enumerable::EmptyError
Returns the first element in the collection.
When the collection is empty, returns nil
.
([1, 2, 3]).first? # => 1
([] of Int32).first? # => nil
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>
Returns the number of elements in the collection.
[1, 2, 3, 4].size # => 4
Returns an Array
with all the elements in the collection.
(1..5).to_a # => [1, 2, 3, 4, 5]
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>