Class DoubleArraySet

All Implemented Interfaces:
DoubleCollection, DoubleIterable, DoubleSet, Serializable, Cloneable, Iterable<Double>, Collection<Double>, Set<Double>

public class DoubleArraySet
extends AbstractDoubleSet
implements Serializable, Cloneable
A simple, brute-force implementation of a set based on a backing array.

The main purpose of this implementation is that of wrapping cleanly the brute-force approach to the storage of a very small number of items: just put them into an array and scan linearly to find an item.

See Also:
Serialized Form
  • Constructor Details

    • DoubleArraySet

      public DoubleArraySet​(double[] a)
      Creates a new array set using the given backing array. The resulting set will have as many elements as the array.

      It is responsibility of the caller that the elements of a are distinct.

      Parameters:
      a - the backing array.
    • DoubleArraySet

      public DoubleArraySet()
      Creates a new empty array set.
    • DoubleArraySet

      public DoubleArraySet​(int capacity)
      Creates a new empty array set of given initial capacity.
      Parameters:
      capacity - the initial capacity.
    • DoubleArraySet

      public DoubleArraySet​(DoubleCollection c)
      Creates a new array set copying the contents of a given collection.
      Parameters:
      c - a collection.
    • DoubleArraySet

      public DoubleArraySet​(Collection<? extends Double> c)
      Creates a new array set copying the contents of a given set.
      Parameters:
      c - a collection.
    • DoubleArraySet

      public DoubleArraySet​(DoubleSet c)
      Creates a new array set copying the contents of a given collection.
      Parameters:
      c - a collection.
    • DoubleArraySet

      public DoubleArraySet​(Set<? extends Double> c)
      Creates a new array set copying the contents of a given set.
      Parameters:
      c - a collection.
    • DoubleArraySet

      public DoubleArraySet​(double[] a, int size)
      Creates a new array set using the given backing array and the given number of elements of the array.

      It is responsibility of the caller that the first size elements of a are distinct.

      Parameters:
      a - the backing array.
      size - the number of valid elements in a.
  • Method Details