Java blocking queue containing only unique elements

后端 未结 5 1183
长发绾君心
长发绾君心 2020-12-11 15:45

sort of like a \"blocking set\". How can I implement a blocking queue where adding a member that is already in the set is ignored?

5条回答
  •  無奈伤痛
    2020-12-11 16:05

    A blocking queue implementation backed by a linked hash set for predictable iteration order and constant time addition, removal and contains operations:

    There you go.

提交回复
热议问题