Class ConcurrentSet<E>

  • Type Parameters:
    E - the element type
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

    public class ConcurrentSet<E>
    extends MapDelegateSet<E>
    implements java.io.Serializable
    Concurrent Set based on top of ConcurrentHashMap. It's serializable if the elements are serializable.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static long serialVersionUID
      The serialVersionUID
    • Constructor Summary

      Constructors 
      Constructor Description
      ConcurrentSet()
      Constructs a new, empty set; the backing ConcurrentHashMap instance has default initial capacity (16) and load factor (0.75).
      ConcurrentSet​(int initialCapacity)
      Constructs a new, empty set; the backing ConcurrentHashMap instance has the specified initial capacity and default load factor, which is 0.75.
      ConcurrentSet​(int initialCapacity, float loadFactor, int concurrencyLevel)
      Constructs a new, empty set; the backing ConcurrentHashMap instance has the specified initial capacity and the specified load factor.
      ConcurrentSet​(java.util.Collection<? extends E> c)
      Constructs a new set containing the elements in the specified collection.
    • Method Summary

      • Methods inherited from class java.util.AbstractSet

        equals, hashCode, removeAll
      • Methods inherited from class java.util.AbstractCollection

        addAll, containsAll, retainAll, toArray, toArray
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Set

        addAll, containsAll, retainAll, spliterator, toArray, toArray
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        The serialVersionUID
        See Also:
        Constant Field Values
    • Constructor Detail

      • ConcurrentSet

        public ConcurrentSet()
        Constructs a new, empty set; the backing ConcurrentHashMap instance has default initial capacity (16) and load factor (0.75).
      • ConcurrentSet

        public ConcurrentSet​(java.util.Collection<? extends E> c)
        Constructs a new set containing the elements in the specified collection. The ConcurrentHashMap is created with default load factor (0.75) and an initial capacity sufficient to contain the elements in the specified collection.
        Parameters:
        c - the collection whose elements are to be placed into this set.
        Throws:
        java.lang.NullPointerException - if the specified collection is null.
      • ConcurrentSet

        public ConcurrentSet​(int initialCapacity,
                             float loadFactor,
                             int concurrencyLevel)
        Constructs a new, empty set; the backing ConcurrentHashMap instance has the specified initial capacity and the specified load factor.
        Parameters:
        initialCapacity - the initial capacity. The implementation performs internal sizing to accommodate this many elements.
        loadFactor - the load factor threshold, used to control resizing. Resizing may be performed when the average number of elements per bin exceeds this threshold.
        concurrencyLevel - the estimated number of concurrently updating threads. The implementation performs internal sizing to try to accommodate this many threads.
        Throws:
        java.lang.IllegalArgumentException - if the initial capacity is less than zero, or if the load factor is nonpositive.
      • ConcurrentSet

        public ConcurrentSet​(int initialCapacity)
        Constructs a new, empty set; the backing ConcurrentHashMap instance has the specified initial capacity and default load factor, which is 0.75.
        Parameters:
        initialCapacity - the initial capacity of the hash table.
        Throws:
        java.lang.IllegalArgumentException - if the initial capacity is less than zero.