I am trying to implement a data structure which allows rapid look-ups based on keys.
The python dict
is great when my look-ups involve an equality
(e.g. key == somevalue
translates to datadict[somevalue]
.
The problem is that I also need to be able to efficiently look up keys based on a more complex comparison, e.g. key > 50
, or key.startswith('abc')
.
Obviously I can't use the same solution in both cases, but at the moment I can't figure out how to solve either case. Can anyone suggest a way of doing this?