Queue with unique entries in c++

后端 未结 4 879
生来不讨喜
生来不讨喜 2021-02-05 07:25

I need to implement a queue containing unique entries(no duplicates) in C or C++. I am thinking of maintaining a reference of elements already available in queue but that seems

4条回答
  •  日久生厌
    2021-02-05 08:18

    queuing:

    • use std::set to maintain your set of unique elements
    • add any element that you were able to add to the std::set to the std::queue

    dequeueing:

    • remove element from std::queue and std::set

提交回复
热议问题