Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/concurrent/parallel.rb

Instance Method Summary collapse

Instance Method Details

#parallel_subsets(n) ⇒ Object



109
110
111
112
113
114
115
116
117
118
# File 'lib/concurrent/parallel.rb', line 109

def parallel_subsets( n )
  if n > 1
    slice_size = size / n
    (0...(( size.to_f / slice_size ).ceil)).map do |i|
      self[i*slice_size, slice_size]
    end
  else
    [ self ]
  end
end