Class IdentityIntSet<T>

  • All Implemented Interfaces:
    java.lang.Cloneable

    public final class IdentityIntSet<T>
    extends java.lang.Object
    implements java.lang.Cloneable
    An efficient identity object set.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int count  
      private java.lang.Object[] keys  
      private int resizeCount  
    • Constructor Summary

      Constructors 
      Constructor Description
      IdentityIntSet()
      Construct a new instance with an initial capacity of 64 and a load factor of 0.5.
      IdentityIntSet​(float loadFactor)
      Construct a new instance with the given load factor and an initial capacity of 64.
      IdentityIntSet​(int initialCapacity)
      Construct a new instance with the given initial capacity and a load factor of 0.5.
      IdentityIntSet​(int initialCapacity, float loadFactor)
      Construct a new instance with the given initial capacity and load factor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(T key)
      Add a value into the set, if it's not already in there.
      void clear()  
      IdentityIntSet<T> clone()
      Clone this set.
      boolean contains​(T key)
      Check to see if this set contains a value.
      private void resize()  
      java.lang.String toString()
      Get a string summary representation of this map.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • keys

        private java.lang.Object[] keys
      • count

        private int count
      • resizeCount

        private int resizeCount
    • Constructor Detail

      • IdentityIntSet

        public IdentityIntSet​(int initialCapacity,
                              float loadFactor)
        Construct a new instance with the given initial capacity and load factor.
        Parameters:
        initialCapacity - the initial capacity
        loadFactor - the load factor
      • IdentityIntSet

        public IdentityIntSet​(float loadFactor)
        Construct a new instance with the given load factor and an initial capacity of 64.
        Parameters:
        loadFactor - the load factor
      • IdentityIntSet

        public IdentityIntSet​(int initialCapacity)
        Construct a new instance with the given initial capacity and a load factor of 0.5.
        Parameters:
        initialCapacity - the initial capacity
      • IdentityIntSet

        public IdentityIntSet()
        Construct a new instance with an initial capacity of 64 and a load factor of 0.5.
    • Method Detail

      • clone

        public IdentityIntSet<T> clone()
        Clone this set.
        Overrides:
        clone in class java.lang.Object
        Returns:
        a cloned set
      • contains

        public boolean contains​(T key)
        Check to see if this set contains a value.
        Parameters:
        key - the key
        Returns:
        true if the object is present in the set
      • add

        public boolean add​(T key)
        Add a value into the set, if it's not already in there.
        Parameters:
        key - the key
        Returns:
        true if the object was added, or false if it was already in the set
      • resize

        private void resize()
      • clear

        public void clear()
      • toString

        public java.lang.String toString()
        Get a string summary representation of this map.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation