Class Array2DHashSet<T>

    • Field Detail

      • buckets

        protected T[][] buckets
      • n

        protected int n
        How many elements in set
      • threshold

        protected int threshold
      • currentPrime

        protected int currentPrime
      • initialBucketCapacity

        protected int initialBucketCapacity
    • Constructor Detail

      • Array2DHashSet

        public Array2DHashSet()
      • Array2DHashSet

        public Array2DHashSet​(AbstractEqualityComparator<? super T> comparator,
                              int initialCapacity,
                              int initialBucketCapacity)
    • Method Detail

      • getOrAdd

        public final T getOrAdd​(T o)
        Add o to set if not there; return existing value if already there. This method performs the same operation as add(T) aside from the return value.
      • getOrAddImpl

        protected T getOrAddImpl​(T o)
      • get

        public T get​(T o)
      • getBucket

        protected final int getBucket​(T o)
      • expand

        protected void expand()
      • add

        public final boolean add​(T t)
        Specified by:
        add in interface Collection<T>
        Specified by:
        add in interface Set<T>
      • size

        public final int size()
        Specified by:
        size in interface Collection<T>
        Specified by:
        size in interface Set<T>
      • containsFast

        public boolean containsFast​(T obj)
      • removeFast

        public boolean removeFast​(T obj)
      • toTableString

        public String toTableString()
      • asElementType

        protected T asElementType​(Object o)
        Return o as an instance of the element type T. If o is non-null but known to not be an instance of T, this method returns null. The base implementation does not perform any type checks; override this method to provide strong type checks for the contains(java.lang.Object) and remove(java.lang.Object) methods to ensure the arguments to the EqualityComparator for the set always have the expected types.
        Parameters:
        o - the object to try and cast to the element type of the set
        Returns:
        o if it could be an instance of T, otherwise null.
      • createBuckets

        protected T[][] createBuckets​(int capacity)
        Return an array of T[] with length capacity.
        Parameters:
        capacity - the length of the array to return
        Returns:
        the newly constructed array
      • createBucket

        protected T[] createBucket​(int capacity)
        Return an array of T with length capacity.
        Parameters:
        capacity - the length of the array to return
        Returns:
        the newly constructed array