module Universa::Parallel
Public Instance Methods
group_by(&block)
click to toggle source
Group elements by the value returned by the block. Return map where keys are one returned by the block and values are arrays of elements of the given Enumerable with corresponding block.
@param [Object] block that calculates keys to group with for each source elements. @return [Hash] of grouped source elements
# File lib/universa/tools.rb, line 90 def group_by(&block) result = {} each {|value| new_key = block.call(value) (result[new_key] ||= []) << value } result end
par()
click to toggle source
Creates {ParallelEnumerable} from self.
@return [ParallelEnumerable] over the self
# File lib/universa/tools.rb, line 81 def par is_a?(ParallelEnumerable) ? self : ParallelEnumerable.new(self) end