Class: SortedSet
- Inherits:
-
Object
- Object
- SortedSet
- Defined in:
- lib/vcap/sorted_set_utils.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_int_array(array) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vcap/sorted_set_utils.rb', line 31 def self.from_int_array(array) set = SortedSet.new current = 0 array.each do |i| current += i set << current end set end |
Instance Method Details
#to_int_array ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vcap/sorted_set_utils.rb', line 19 def to_int_array array = [] former = 0 self.each do |i| array << i - former former = i end array end |