I'm using python to manage a queue of strings to process. It has a couple of requirments:
- Each string is matched to a priority and is processed based solely on that value.
- Strings can be added to this queue dynamically but no duplicate Strings are allowed in the queue. If a duplicate is submitted then it must be identified and ignored.
So is there any python datatype that will allow something like this? Or do I have to write my own?
If there isn't a native one then, I'm thinking of maintaining two structures.
- A heapq which will maintain the strings and their priority
- A list which maintains a hash of the strings to check whether the string is already stored
As long as these do not fall out of sync it should solve the problem.