4 ms·
Sounds like a priority queue
by kgeist 4y ago
Sounds like a priority queue
- vosper 4y agoIs 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.
- deleted 4y ago[deleted]
- Tmpod 4y agoNot really. In a priority queue, an item with higher priority gets pulled out before one with lower priority, so you can have items that skip parts of the queue (or all of it) even if there are no items of the same priority in there already. This structure seems to behave differently, in that an item may skip ahead in the queue if and only if another item with some matching characteristic is already contained. This makes it so you can never skip the whole structure, for example, assuming you get put after your "friend".