Class MostlySingletonSet<T>

java.lang.Object
org.plumelib.util.AbstractMostlySingletonSet<T>
org.plumelib.util.MostlySingletonSet<T>
Type Parameters:
T - the type of elements of the set
All Implemented Interfaces:
Iterable<T>, Collection<T>, Set<T>

public final class MostlySingletonSet<T> extends AbstractMostlySingletonSet<T>
A set that is more efficient than HashSet for 0 and 1 elements. Uses Objects.equals for object comparison and a LinkedHashSet for backing storage.

Usually, you should use ArraySet instead. The advantage of this over ArraySet is that this is efficient for large sets.

  • Constructor Details

    • MostlySingletonSet

      public MostlySingletonSet()
      Create a MostlySingletonSet.
    • MostlySingletonSet

      public MostlySingletonSet(T value)
      Create a MostlySingletonSet containing one value.
      Parameters:
      value - the single element of the set
  • Method Details

    • add

      public boolean add(@GuardSatisfied MostlySingletonSet<T> this, T e)
    • contains

      public boolean contains(@GuardSatisfied MostlySingletonSet<T> this, @GuardSatisfied @UnknownSignedness Object o)