Class IdentitySet

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

    public final class IdentitySet
    extends java.lang.Object
    implements java.util.Set
    An IdentitySet that uses reference-equality instead of object-equality. According to its special function it violates some design contracts of the Set interface.
    Since:
    0.9.9
    Version:
    $Revision: 7491 $ $Date: 2006-04-13 10:49:49 -0600 (Thu, 13 Apr 2006) $
    Author:
    Ralf Joachim
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  IdentitySet.Entry
      An entry of the IdentitySet.
    • Constructor Summary

      Constructors 
      Constructor Description
      IdentitySet()
      Construct a set with default capacity.
      IdentitySet​(int capacity)
      Construct a set with given capacity.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(java.lang.Object key)
      boolean addAll​(java.util.Collection c)
      This optional method has not been implemented for IdentitySet instead it throws a UnsupportedOperationException as defined in the Set interface.
      void clear()
      boolean contains​(java.lang.Object key)
      boolean containsAll​(java.util.Collection c)
      In contrast with the design contract of the Set interface this method has not been implemented and throws a UnsupportedOperationException.
      boolean isEmpty()
      java.util.Iterator iterator()
      boolean remove​(java.lang.Object key)
      boolean removeAll​(java.util.Collection c)
      This optional method has not been implemented for IdentitySet instead it throws a UnsupportedOperationException as defined in the Set interface.
      boolean retainAll​(java.util.Collection c)
      This optional method has not been implemented for IdentitySet instead it throws a UnsupportedOperationException as defined in the Set interface.
      int size()
      java.lang.Object[] toArray()
      java.lang.Object[] toArray​(java.lang.Object[] a)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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

        equals, hashCode, spliterator
    • Constructor Detail

      • IdentitySet

        public IdentitySet()
        Construct a set with default capacity.
      • IdentitySet

        public IdentitySet​(int capacity)
        Construct a set with given capacity.
        Parameters:
        capacity - The capacity of entries this set should be initialized with.
    • Method Detail

      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection
        Specified by:
        clear in interface java.util.Set
        See Also:
        Collection.clear()
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection
        Specified by:
        size in interface java.util.Set
        See Also:
        Collection.size()
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection
        Specified by:
        isEmpty in interface java.util.Set
        See Also:
        Collection.isEmpty()
      • add

        public boolean add​(java.lang.Object key)
        Specified by:
        add in interface java.util.Collection
        Specified by:
        add in interface java.util.Set
        See Also:
        Collection.add(java.lang.Object)
      • contains

        public boolean contains​(java.lang.Object key)
        Specified by:
        contains in interface java.util.Collection
        Specified by:
        contains in interface java.util.Set
        See Also:
        Collection.contains(java.lang.Object)
      • remove

        public boolean remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Collection
        Specified by:
        remove in interface java.util.Set
        See Also:
        Collection.remove(java.lang.Object)
      • iterator

        public java.util.Iterator iterator()
        Specified by:
        iterator in interface java.util.Collection
        Specified by:
        iterator in interface java.lang.Iterable
        Specified by:
        iterator in interface java.util.Set
        See Also:
        Collection.iterator()
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection
        Specified by:
        toArray in interface java.util.Set
        See Also:
        Collection.toArray()
      • toArray

        public java.lang.Object[] toArray​(java.lang.Object[] a)
        Specified by:
        toArray in interface java.util.Collection
        Specified by:
        toArray in interface java.util.Set
        See Also:
        Collection.toArray(java.lang.Object[])
      • containsAll

        public boolean containsAll​(java.util.Collection c)
        In contrast with the design contract of the Set interface this method has not been implemented and throws a UnsupportedOperationException.
        Specified by:
        containsAll in interface java.util.Collection
        Specified by:
        containsAll in interface java.util.Set
        See Also:
        Set.containsAll(java.util.Collection<?>)
      • addAll

        public boolean addAll​(java.util.Collection c)
        This optional method has not been implemented for IdentitySet instead it throws a UnsupportedOperationException as defined in the Set interface.
        Specified by:
        addAll in interface java.util.Collection
        Specified by:
        addAll in interface java.util.Set
        See Also:
        Set.addAll(java.util.Collection<? extends E>)
      • removeAll

        public boolean removeAll​(java.util.Collection c)
        This optional method has not been implemented for IdentitySet instead it throws a UnsupportedOperationException as defined in the Set interface.
        Specified by:
        removeAll in interface java.util.Collection
        Specified by:
        removeAll in interface java.util.Set
        See Also:
        Set.removeAll(java.util.Collection<?>)
      • retainAll

        public boolean retainAll​(java.util.Collection c)
        This optional method has not been implemented for IdentitySet instead it throws a UnsupportedOperationException as defined in the Set interface.
        Specified by:
        retainAll in interface java.util.Collection
        Specified by:
        retainAll in interface java.util.Set
        See Also:
        Set.retainAll(java.util.Collection<?>)