Rejuicer is easy search engine.
index = Rejuicer.new(:odd_flag, :remainder_3, :remainder_5)
work = Struct.new(:id, :odd_flag, :remainder_3, :remainder_5) mother = (0...10000).inject([]){|m, i| m << work.new(i, i % 2 == 0, i % 3, i % 5)} index.set(mother)
num = 20000 inst = work.new(num, num % 2 == 0, num % 3, num % 5) index.add(inst)
index.delete(inst)
index.search(:odd_flag => false) #=> [1,3,5,7,9...,9997,9999] index.search(:remainder_3 => 2, :remainder_5 => 4) #=> [14,29,44,59,...,9974,9989]
sudo gem install rejuicer
Rejuicer is released under the MIT license.