Is it the same thing? I'm trying to imagine how this would work with a priority queue.
I think you need an flexible number of priorities that is equal to the queue length, and the priority values come from an infinite counter that only goes up. Higher values = lower priority.
When a unique item comes into the queue you increment the counter and give it that value as a priority. This puts it on the end of the queue.
But if the new item is a duplicate of an existing item then you give it the priority of the existing item.
I think you need an flexible number of priorities that is equal to the queue length, and the priority values come from an infinite counter that only goes up. Higher values = lower priority.
When a unique item comes into the queue you increment the counter and give it that value as a priority. This puts it on the end of the queue.
But if the new item is a duplicate of an existing item then you give it the priority of the existing item.