Class ArraySet<E>

java.lang.Object
com.yahoo.collections.ArraySet<E>
Type Parameters:
E - the type contained in the Set
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>

public final class ArraySet<E> extends Object implements Set<E>
A Set implementation with low allocation cost. It should only be used for small number of objects, as it is implemented as scanning an ArrayList for equality matches. In other words: Performance will only be acceptable for small sets.

The rationale for this class is the high cost of the object identifier used in IdentityHashMap, where the key set is often used as an identity set.

Author:
Steinar Knutsen, baldersheim
  • Constructor Details

    • ArraySet

      public ArraySet(int initSize)
      Create a set with an initial capacity of initSize. The internal array will grow automatically with a linear growth rate if more elements than initSize are added.
      Parameters:
      initSize - initial size of internal element array
  • Method Details