How to move a specific entry to the header of the queue in c?
As w开发者_如何学Goe know queue is FIFO
,does it support such kind of operation?
No. If you want to be be able to put objects at specific positions, a queue is not the right data structure.
A deque lets you insert new items at either the back or the front. Once inserted, however, you can't normally rearrange them.
A priority queue maintains some specified ordering among the items, so the "next" is always the highest priority (based on some criteria you need to establish).
If you want to rearrange items after insertion, then you're normally looking at something that isn't very queue-like at all (much more like a normal array).
It sounds to me like you're looking for a priority queue.
精彩评论