Class IdentityHashSet

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.Set

    public class IdentityHashSet
    extends java.util.AbstractCollection
    implements java.util.Set, java.lang.Cloneable, java.io.Serializable
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int count  
      protected org.eclipse.persistence.internal.helper.IdentityHashSet.Entry[] entries  
      protected float loadFactor  
      protected int threshold  
    • Constructor Summary

      Constructors 
      Constructor Description
      IdentityHashSet()
      Constructs a new IdentityHashSet with a default initial capacity of 32 and a loadfactor of 0.75.
      IdentityHashSet​(int initialCapacity)
      Constructs a new IdentityHashSet with the given initial capacity and a default loadFactor of 0.75.
      IdentityHashSet​(int initialCapacity, float loadFactor)
      Constructs a new IdentityHashSet with the given initial capacity and the given loadFactor.
      IdentityHashSet​(java.util.Collection c)
      Constructs a new IdentityHashSet with the same contents as the given Collection.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(java.lang.Object obj)
      Adds the given object to this IdentityHashSet.
      void clear()
      Removes all of the objects from this IdentityHashSet.
      java.lang.Object clone()
      Returns a shallow copy of this IdentityHashSet (the elements are not cloned).
      boolean contains​(java.lang.Object obj)
      Returns true if this IdentityHashSet contains the given object.
      boolean isEmpty()  
      java.util.Iterator iterator()
      Get an iterator for this IdentityHashSet
      boolean remove​(java.lang.Object obj)
      Removes the given object from this IdentityHashSet, if present.
      boolean removeAll​(java.util.Collection c)
      This implementation throws an UnsupportedOperationException because removeAll does not work correctly with reference equality testing.
      boolean retainAll​(java.util.Collection c)
      This implementation throws an UnsupportedOperationException.
      int size()  
      • Methods inherited from class java.util.AbstractCollection

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

        equals, finalize, getClass, hashCode, 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, equals, hashCode, spliterator, toArray, toArray
    • Field Detail

      • entries

        protected transient org.eclipse.persistence.internal.helper.IdentityHashSet.Entry[] entries
      • count

        protected transient int count
      • threshold

        protected int threshold
      • loadFactor

        protected float loadFactor
    • Constructor Detail

      • IdentityHashSet

        public IdentityHashSet​(int initialCapacity,
                               float loadFactor)
        Constructs a new IdentityHashSet with the given initial capacity and the given loadFactor.
        Parameters:
        initialCapacity - the initial capacity of the IdentityHashSet.
        loadFactor - the loadFactor of the IdentityHashSet.
      • IdentityHashSet

        public IdentityHashSet​(int initialCapacity)
        Constructs a new IdentityHashSet with the given initial capacity and a default loadFactor of 0.75.
        Parameters:
        initialCapacity - the initial capacity of the IdentityHashSet.
      • IdentityHashSet

        public IdentityHashSet()
        Constructs a new IdentityHashSet with a default initial capacity of 32 and a loadfactor of 0.75.
      • IdentityHashSet

        public IdentityHashSet​(java.util.Collection c)
        Constructs a new IdentityHashSet with the same contents as the given Collection. The new IdentityHashSet is created with an initial capacity sufficient to hold the elements of the given Collection.
        Parameters:
        c - the Collection whose contents are to be placed in the new IdentityHashSet.
    • Method Detail

      • size

        public int size()
        Specified by:
        size in interface java.util.Collection
        Specified by:
        size in interface java.util.Set
        Specified by:
        size in class java.util.AbstractCollection
        Returns:
        the size of this IdentityHashSet.
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection
        Specified by:
        isEmpty in interface java.util.Set
        Overrides:
        isEmpty in class java.util.AbstractCollection
        Returns:
        true if this IdentityHashSet is empty.
      • contains

        public boolean contains​(java.lang.Object obj)
        Returns true if this IdentityHashSet contains the given object.
        Specified by:
        contains in interface java.util.Collection
        Specified by:
        contains in interface java.util.Set
        Overrides:
        contains in class java.util.AbstractCollection
        Parameters:
        obj - the object to find.
        Returns:
        true if this IdentityHashSet contains obj by reference.
      • add

        public boolean add​(java.lang.Object obj)
        Adds the given object to this IdentityHashSet.
        Specified by:
        add in interface java.util.Collection
        Specified by:
        add in interface java.util.Set
        Overrides:
        add in class java.util.AbstractCollection
        Parameters:
        obj - object to add.
        Returns:
        true if this IdentityHashSet did not already contain obj.
      • remove

        public boolean remove​(java.lang.Object obj)
        Removes the given object from this IdentityHashSet, if present.
        Specified by:
        remove in interface java.util.Collection
        Specified by:
        remove in interface java.util.Set
        Overrides:
        remove in class java.util.AbstractCollection
        Parameters:
        obj - the object to be removed from this IdentityHashSet.
        Returns:
        true if this IdentityHashSet contained obj.
      • removeAll

        public boolean removeAll​(java.util.Collection c)
        This implementation throws an UnsupportedOperationException because removeAll does not work correctly with reference equality testing.

        Specified by:
        removeAll in interface java.util.Collection
        Specified by:
        removeAll in interface java.util.Set
        Overrides:
        removeAll in class java.util.AbstractCollection
      • retainAll

        public boolean retainAll​(java.util.Collection c)
        This implementation throws an UnsupportedOperationException. The Javadocs for AbstractCollection indicates that retainAll is an optional method.

        Specified by:
        retainAll in interface java.util.Collection
        Specified by:
        retainAll in interface java.util.Set
        Overrides:
        retainAll in class java.util.AbstractCollection
      • clear

        public void clear()
        Removes all of the objects from this IdentityHashSet.
        Specified by:
        clear in interface java.util.Collection
        Specified by:
        clear in interface java.util.Set
        Overrides:
        clear in class java.util.AbstractCollection
      • clone

        public java.lang.Object clone()
        Returns a shallow copy of this IdentityHashSet (the elements are not cloned).
        Overrides:
        clone in class java.lang.Object
        Returns:
        a shallow copy of this IdentityHashSet.
      • iterator

        public java.util.Iterator iterator()
        Get an iterator for this IdentityHashSet
        Specified by:
        iterator in interface java.util.Collection
        Specified by:
        iterator in interface java.lang.Iterable
        Specified by:
        iterator in interface java.util.Set
        Specified by:
        iterator in class java.util.AbstractCollection