Key-based container with custom sort order?
-
I am looking for a container with fast key-based lookup (like QHash, QMap), but where I can choose in which order items are inserted (like QList). I think that none of the Qt or std containers can provide that, but I hope you can prove me wrong.
-
The fast lookup is achieved by optimizing the order of the items, so what you're asking is not possible with standard containers.
-
Technically, such a container would require two separate tables internally. I just hoped such a construct already existed.
-
Hi,
containers like the map are based on the comparison operators: if you encapsulates you keys inside a class with operators based on your sort algorithm, that would do the trick.
-
Unfortunately, not an option here. They keys I need for searching have their own sort order, nothing I can influence.
-
What I meant is that you can influence by storing the keys in a structure in which you can define sort order (?)