Class NonBlockingHashSet<E>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

    public class NonBlockingHashSet<E>
    extends java.util.AbstractSet<E>
    implements java.io.Serializable
    A simple wrapper around NonBlockingHashMap making it implement the Set interface. All operations are Non-Blocking and multi-thread safe.
    Since:
    1.5
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private NonBlockingHashMap<E,​java.lang.Object> _map  
      private static java.lang.Object V  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(E o)
      Add o to the set.
      void clear()
      Empty the set.
      boolean contains​(java.lang.Object o)  
      E get​(E o)  
      java.util.Iterator<E> iterator()  
      boolean remove​(java.lang.Object o)
      Remove o from the set.
      int size()
      Current count of elements in the set.
      • Methods inherited from class java.util.AbstractSet

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

        addAll, containsAll, isEmpty, retainAll, toArray, toArray, toString
      • 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, isEmpty, retainAll, spliterator, toArray, toArray
    • Field Detail

      • V

        private static final java.lang.Object V
    • Constructor Detail

    • Method Detail

      • add

        public boolean add​(E o)
        Add o to the set.
        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface java.util.Set<E>
        Overrides:
        add in class java.util.AbstractCollection<E>
        Returns:
        true if o was added to the set, false if o was already in the set.
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface java.util.Set<E>
        Overrides:
        contains in class java.util.AbstractCollection<E>
        Returns:
        true if o is in the set.
      • get

        public E get​(E o)
        Returns:
        Returns the match for o if o is in the set.
      • remove

        public boolean remove​(java.lang.Object o)
        Remove o from the set.
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface java.util.Set<E>
        Overrides:
        remove in class java.util.AbstractCollection<E>
        Returns:
        true if o was removed to the set, false if o was not in the set.
      • size

        public int size()
        Current count of elements in the set. Due to concurrent racing updates, the size is only ever approximate. Updates due to the calling thread are immediately visible to calling thread.
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface java.util.Set<E>
        Specified by:
        size in class java.util.AbstractCollection<E>
        Returns:
        count of elements.
      • clear

        public void clear()
        Empty the set.
        Specified by:
        clear in interface java.util.Collection<E>
        Specified by:
        clear in interface java.util.Set<E>
        Overrides:
        clear in class java.util.AbstractCollection<E>
      • iterator

        public java.util.Iterator<E> iterator()
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in interface java.util.Set<E>
        Specified by:
        iterator in class java.util.AbstractCollection<E>