Class CompactHashSet<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
net.ontopia.utils.CompactHashSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>
Direct Known Subclasses:
CompactIdentityHashSet, SynchronizedCompactHashSet, TreeWidget.UniversalSet, UniqueSet

public class CompactHashSet<E> extends AbstractSet<E>
INTERNAL: Implements the Set interface more compactly than java.util.HashSet by using a closed hashtable.
  • Field Details

    • INITIAL_SIZE

      protected static final int INITIAL_SIZE
      See Also:
    • LOAD_FACTOR

      protected static final double LOAD_FACTOR
      See Also:
    • nullObject

      protected static final Object nullObject
      This object is used to represent null, should clients add that to the set.
    • deletedObject

      protected static final Object deletedObject
      When an object is deleted this object is put into the hashtable in its place, so that other objects with the same key (collisions) further down the hashtable are not lost after we delete an object in the collision chain.
    • elements

      protected int elements
    • freecells

      protected int freecells
      This is the number of empty (null) cells. It's not necessarily the same as objects.length - elements, because some cells may contain deletedObject.
    • objects

      protected E[] objects
    • modCount

      protected int modCount
  • Constructor Details

    • CompactHashSet

      public CompactHashSet()
      Constructs a new, empty set.
    • CompactHashSet

      public CompactHashSet(int size)
      Constructs a new, empty set.
    • CompactHashSet

      public CompactHashSet(Collection<E> c)
      Constructs a new set containing the elements in the specified collection.
      Parameters:
      c - the collection whose elements are to be placed into this set.
  • Method Details