My question is akin to Data structure for partial multi-keys mapping?.
I have key-value pairs where the key is composed of three components (strings).
I am looking for a data structure the can efficiently perform search queries over keys, where the queries could be complete or partial specification the key (one or more components omitted). For example:
(x, y, z)
(x, *, *)
(*, y, *)
etc.
The unspecified part of the key can be either at the front, the middle or the end of the key.
My current implementation (a hash map which maps all possible partial keys to a set of values that match this partial key) is horribly slow when inserting, deleting and updating values.
My current implementation (a hash map which maps all possible partial keys to a list of values that match this partial key) is horribly slow when inserting, deleting and updating values.
If you are actually using a list then that is almost certainly the issue as they are slow on deleting/updating/inserting may also be an issue depending on how you are doing it. You are better off using a set (unordered) or balanced binary search tree (ordered).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With