Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/achoo/extensions.rb
Direct Known Subclasses
Achoo::Achievo::Table, Achoo::System::PMSuspend, Achoo::System::Wtmp
Instance Method Summary collapse
-
#merge!(other) ⇒ Object
Useful for merging two sorted arrays with Comparable elements.
Instance Method Details
#merge!(other) ⇒ Object
Useful for merging two sorted arrays with Comparable elements.
The content of the two input arrays should not be trusted after being mistreated by this method.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/achoo/extensions.rb', line 14 def merge!(other) # FIX raise exception if merge is defined? array = [] until empty? or other.empty? if first <= other.first array << shift else array << other.shift end end array.concat(self).concat(other) array end |