Class ReferenceImmutableList<K>

All Implemented Interfaces:
it.unimi.dsi.fastutil.objects.ObjectIterable<K>, ReferenceCollection<K>, ReferenceList<K>, it.unimi.dsi.fastutil.Stack<K>, Serializable, Cloneable, Iterable<K>, Collection<K>, List<K>, RandomAccess, SequencedCollection<K>

public class ReferenceImmutableList<K> extends AbstractReferenceList<K> implements ReferenceList<K>, RandomAccess, Cloneable, Serializable
A type-specific array-based immutable list; provides some additional methods that use polymorphism to avoid (un)boxing.

Instances of this class are immutable and (contrarily to mutable array-based list implementations) the backing array is not exposed. Instances can be built using a variety of methods, but note that constructors using an array will not make a defensive copy.

This class implements the bulk method getElements() using high-performance system calls (e.g., System.arraycopy()) instead of expensive loops.

See Also:
  • Constructor Details

    • ReferenceImmutableList

      public ReferenceImmutableList(K[] a)
      Creates a new immutable list using a given array.

      Note that this constructor does not perform a defensive copy.

      Parameters:
      a - the array that will be used to back this immutable list.
    • ReferenceImmutableList

      public ReferenceImmutableList(Collection<? extends K> c)
      Creates a new immutable list and fills it with a given collection.
      Parameters:
      c - a collection that will be used to fill the immutable list.
    • ReferenceImmutableList

      public ReferenceImmutableList(ReferenceCollection<? extends K> c)
      Creates a new immutable list and fills it with a given type-specific collection.
      Parameters:
      c - a type-specific collection that will be used to fill the immutable list.
    • ReferenceImmutableList

      public ReferenceImmutableList(ReferenceList<? extends K> l)
      Creates a new immutable list and fills it with a given type-specific list.
      Parameters:
      l - a type-specific list that will be used to fill the immutable list.
    • ReferenceImmutableList

      public ReferenceImmutableList(K[] a, int offset, int length)
      Creates a new immutable list and fills it with the elements of a given array.
      Parameters:
      a - an array whose elements will be used to fill the immutable list.
      offset - the first element to use.
      length - the number of elements to use.
    • ReferenceImmutableList

      public ReferenceImmutableList(it.unimi.dsi.fastutil.objects.ObjectIterator<? extends K> i)
      Creates a new immutable list and fills it with the elements returned by a type-specific iterator..
      Parameters:
      i - a type-specific iterator whose returned elements will fill the immutable list.
  • Method Details