Priority Queue with a find function - Fastest Implementation

前端 未结 7 2266
一向
一向 2021-02-07 13:24

I am looking at implementing a priority queue with an added requirement, a find/search function which will tell whether an item is anywhere within the queue. So the functions wi

7条回答
  •  耶瑟儿~
    2021-02-07 13:41

    Why can't you just use a Priority Queue and a Set? When you enqueue something, you add it to the set. When you dequeue it, you remove it from the set. That way the set will tell you if something is in the queue.

提交回复
热议问题