I am using python to control the line queue for processing. He has several requirements:
- Each line corresponds to priority and is processed only on the basis of this value.
- Lines can be added to this queue dynamically, but duplicate lines are not allowed in the queue. If a duplicate is presented, it must be identified and ignored.
So, is there any python data type that will allow something like this? Or do I need to write my own?
If there is no native, I think about maintaining two structures.
- A heapq that will support strings and their priority
- A list that supports a hash of strings to check if a string is already saved
Until they fall out of sync, he should solve the problem.
source
share