Class LongImmutableList

All Implemented Interfaces:
LongCollection, LongIterable, LongList, LongStack, it.unimi.dsi.fastutil.Stack<Long>, Serializable, Cloneable, Comparable<List<? extends Long>>, Iterable<Long>, Collection<Long>, List<Long>, RandomAccess, SequencedCollection<Long>

public class LongImmutableList extends AbstractLongList implements LongList, 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

    • LongImmutableList

      public LongImmutableList(long[] 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.
    • LongImmutableList

      public LongImmutableList(Collection<? extends Long> 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.
    • LongImmutableList

      public LongImmutableList(LongCollection 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.
    • LongImmutableList

      public LongImmutableList(LongList 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.
    • LongImmutableList

      public LongImmutableList(long[] 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.
    • LongImmutableList

      public LongImmutableList(it.unimi.dsi.fastutil.longs.LongIterator 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