大きな配列を作るのを嫌ってイテレータを作った
65
def each_in(range)
return enum_for(__method__, range) unless block_given?
range.each {|x| yield(@deck[x])}
end
def _search_by_deck(v, n)
((
[email protected]).step(@deck.size / @nproc) + [@deck.size]).each_cons(2).map {|s, e|
Ractor.new(self, each_in(s...e), v, n) {|world, sub_decks, v, n|
world._search_by_deck_core(sub_decks, v, n)
}
}.map {|r| r.take}.sum([]).max(n)
end
enum of subrange
subrange iterator