Hi
So here is my problem. I want to store 2-tuple (key, val) and want to perform following operations:
- keys are strings and values are Integers
- multiple keys can have same value
- adding new tuples
- updating any key with new value (any new value or updated value is greater than the previous one, like timestamps)
- fetching all the keys with values less than or greater than given value
- deleting tuples.
Hash seems to be the obvious choice for updating the key's value but then lookups via values will be going to take longer (O(n)). The other option is balanced binary search tree with key and value switched. So now lookups via values will be fast (O(lg(n))) but updating a key will take (O(n)). So is there any data-structure which can be used to address these issues?
Thanks.