Class: Array
Defined Under Namespace
Classes: Tag
Instance Method Summary collapse
-
#bin_search(elem, low = 0, high = -1)) ⇒ Fixnum
Binary search for the first elem that is leq elem in this array in the range (low..high-1).
-
#tag! ⇒ self
Wraps all objects in self into ::Array::Tag instances using the provided block to extract a key.
-
#untag! ⇒ self
Untags Array::Tag instances, i.e.
Instance Method Details
#bin_search(elem, low = 0, high = -1)) ⇒ Fixnum
Binary search for the first elem that is leq elem in this array in the range (low..high-1)
The array is expected to be sorted in descending order.
35 36 37 38 |
# File 'lib/andromeda/patch/array_bin_search.rb', line 35 def bin_search(elem, low = 0, high = -1) high = size - 1 if high < 0 _bin_search elem, low, high end |
#tag! ⇒ self
Wraps all objects in self into ::Array::Tag instances using the provided block to extract a key
45 |
# File 'lib/andromeda/patch/array_bin_search.rb', line 45 def tag! ; map! { |e| Tag.new (yield e), e } end |
#untag! ⇒ self
Untags Array::Tag instances, i.e. replaces them with their value
51 |
# File 'lib/andromeda/patch/array_bin_search.rb', line 51 def untag! ; map! { |e| e.untagged } end |