search

Home  >  Q&A  >  body text

c++ stl 有没有无重复元素队列这样的容器?

c++ stl 有没有无重复元素队列这样的容器 ?

我用unordered_set试过是可以的,就是不知道还有没有其他符合这种特性的容器。

大家讲道理大家讲道理2803 days ago975

reply all(4)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 13:15:01

    You need a queue and no duplication, so you have to index it yourself, so you need to use two containers together. You can consider queue + set/unordered_set. When inserting an object, first check whether the object is in the set. If it is, it will fail. If it is not, it will be added to both containers at the same time. Do the opposite when popping out.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 13:15:01

    use {vector/deque/list} + {set/unordered_set}

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 13:15:01

    A single container cannot satisfy, but you can achieve it yourself. You need to look at the usage scenarios to decide how to implement drunkenness appropriately,

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:15:01

    No. Let me know what scene you need.

    reply
    0
  • Cancelreply