有什么像boost :: multi_index但是对于ruby。基本上采取一些容器的对象,并使用N种不同的查询方法对N个不同的方式编制索引。ruby的多索引容器
我想你可以在内存数据库中使用SQLite的DataMapper,但我想知道是否有任何纯粹的红宝石。
下面是这种类型可能做的一个想象的例子。它看起来非常像数据库,非常类似于 。
class Foo
attr_accessor :a
attr_accessor :b
attr_accessor :c
end
class FooIndexer < MultiIndex
hash_index :a do |o|
o.a
end
ordered_index :b do |x, y|
x.b <=> y.b
end
end
index = FooIndexer.new
index.insert(Foo.new (...))
index.insert(Foo.new (...))
index.insert(Foo.new (...))
index.insert(Foo.new (...))
index.insert(Foo.new (...))
index.find (index.a == 10)
index.find (index.b > 10 )
也许你可以举一个boost :: multi_index的例子用例吗? – AboutRuby 2010-09-01 01:07:12