How to remove duplicates from a thread-safe queue (for example, a ConcurrentQueue) with maximum performance?

  • one
    Describe the task as a whole. How do duplicate data get into this queue? Maybe duplicates can be deleted beforehand, before placing the data in the queue? Is the queue "free" at the moment or are other threads working with it? - Alexander Petrov
  • 2
    In fact, it is not clear how to do it correctly, at least with some performance. What if during enumeration elements are added and disappear? - VladD 9:26 pm

1 answer 1

There is an old estimate for C ++ that the conversion to set was the fastest.

enter image description here

  • what's the advantage? - Alexis
  • @Alexis is the opinion that this is a fundamental task that depends little on the language. - gbg