Class IdentityMostlySingletonSet<T>

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

public final class IdentityMostlySingletonSet<T> extends AbstractMostlySingletonSet<T>
An arbitrary-size set that is very efficient (more efficient than HashSet) for 0 and 1 elements. Uses object identity for object comparison.

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

  • Constructor Details

    • IdentityMostlySingletonSet

      public IdentityMostlySingletonSet()
      Create an IdentityMostlySingletonSet.
    • IdentityMostlySingletonSet

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

    • add

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

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