NgLib::WaveletMatrix(T)
Inherits Indexable < Enumerable < Iterable < Reference < Object
非負整数列 $A$ に対して、順序に関する様々なクエリに答えます。
ジェネリクス T は #[] などでの返却値の型を指定するものであって、
数列の値は非負整数でなければならないことに注意してください。
基本的には CompressedWaveletMatrix の方が高速です。
Constructors
Instance methods
range の表す区間に含まれる要素の中で bound が表す範囲の値の個数を返します。
range の表す区間に含まれる要素のうち、upper_bound 未満 の値の個数を返します。
存在しない場合は nil を返します。
range の表す区間に含まれる要素のうち、kth 番目に大きい値を返します。
wm = WaveletMatrix.new([1, 3, 2, 5])
wm.kth_largest(1..2, 0) # => 3
wm.kth_largest(1..2, 1) # => 2
kth_largest(kth : Int32)
kth 番目に大きい値を返します。
wm = WaveletMatrix.new([1, 3, 2, 5])
wm.kth_smallest(0) # => 5
wm.kth_smallest(1) # => 3
wm.kth_smallest(2) # => 2
wm.kth_smallest(3) # => 1
range の表す区間に含まれる要素のうち、kth 番目に小さい値を返します。
wm = WaveletMatrix.new([1, 3, 2, 5])
wm.kth_smallest(1..2, 0) # => 2
wm.kth_smallest(1..2, 1) # => 3
kth_smallest(kth : Int32)
kth 番目に小さい値を返します。
wm = WaveletMatrix.new([1, 3, 2, 5])
wm.kth_smallest(0) # => 1
wm.kth_smallest(1) # => 2
wm.kth_smallest(2) # => 3
wm.kth_smallest(3) # => 5
range の表す区間に含まれる要素のうち、lower_bound 以上 の値の最小値を返します。
存在しない場合は nil を返します。
range の表す区間に含まれる要素のうち、upper_bound 未満 の値の最大値を返します。
存在しない場合は nil を返します。
size(*args, **options)
Sourcesize(*args, **options, &)
Source