A
Avdi Grimm
Does anyone know of a multi-index container library for Ruby? I just
want to check before I put it on my personal TODO list.
By multi-index, I mean a container which will index its contained
objects by more than one attribute. E.g. something along these lines:
mi = MultiIndex.new
mi.add_indexprefix) {|val| val[0,3]}
mi.add_indexsize)
mi << "foobar"
mi << "foobaz"
mi << "fuzz"
mi << "fuzzbizz"
mi.by_prefix("foo") # => ["foobar", "foobaz"]
mi.by_prefix("fuz") # => ["fuzz", "fuzzbizz"]
mi.by_size(4) # => ["fuzz"]
mi.by_size(8) #= ["fuzzbizz"]
Yes, I know I can just uses #select on Ruby's existing containers, but
the idea here is that a MultiIndex would index each attribute on
insert, making lookups faster than using a #select.
So: does this exist?
--
Avdi
Home: http://avdi.org
Developer Blog: http://avdi.org/devblog/
Twitter: http://twitter.com/avdi
Journal: http://avdi.livejournal.com
want to check before I put it on my personal TODO list.
By multi-index, I mean a container which will index its contained
objects by more than one attribute. E.g. something along these lines:
mi = MultiIndex.new
mi.add_indexprefix) {|val| val[0,3]}
mi.add_indexsize)
mi << "foobar"
mi << "foobaz"
mi << "fuzz"
mi << "fuzzbizz"
mi.by_prefix("foo") # => ["foobar", "foobaz"]
mi.by_prefix("fuz") # => ["fuzz", "fuzzbizz"]
mi.by_size(4) # => ["fuzz"]
mi.by_size(8) #= ["fuzzbizz"]
Yes, I know I can just uses #select on Ruby's existing containers, but
the idea here is that a MultiIndex would index each attribute on
insert, making lookups faster than using a #select.
So: does this exist?
--
Avdi
Home: http://avdi.org
Developer Blog: http://avdi.org/devblog/
Twitter: http://twitter.com/avdi
Journal: http://avdi.livejournal.com