Class ImmutableArray<T>

java.lang.Object
com.landawn.abacus.util.ImmutableArray<T>
All Implemented Interfaces:
Immutable, Iterable<T>

@Immutable public final class ImmutableArray<T> extends Object implements Iterable<T>, Immutable
  • Method Details

    • of

      public static <T> ImmutableArray<T> of(T e1)
      Type Parameters:
      T -
      Parameters:
      e1 -
      Returns:
    • of

      public static <T> ImmutableArray<T> of(T e1, T e2)
      Type Parameters:
      T -
      Parameters:
      e1 -
      e2 -
      Returns:
    • of

      public static <T> ImmutableArray<T> of(T e1, T e2, T e3)
      Type Parameters:
      T -
      Parameters:
      e1 -
      e2 -
      e3 -
      Returns:
    • of

      public static <T> ImmutableArray<T> of(T e1, T e2, T e3, T e4)
      Type Parameters:
      T -
      Parameters:
      e1 -
      e2 -
      e3 -
      e4 -
      Returns:
    • of

      public static <T> ImmutableArray<T> of(T e1, T e2, T e3, T e4, T e5)
      Type Parameters:
      T -
      Parameters:
      e1 -
      e2 -
      e3 -
      e4 -
      e5 -
      Returns:
    • of

      public static <T> ImmutableArray<T> of(T e1, T e2, T e3, T e4, T e5, T e6)
      Type Parameters:
      T -
      Parameters:
      e1 -
      e2 -
      e3 -
      e4 -
      e5 -
      e6 -
      Returns:
    • of

      public static <T> ImmutableArray<T> of(T e1, T e2, T e3, T e4, T e5, T e6, T e7)
      Type Parameters:
      T -
      Parameters:
      e1 -
      e2 -
      e3 -
      e4 -
      e5 -
      e6 -
      e7 -
      Returns:
    • of

      public static <T> ImmutableArray<T> of(T e1, T e2, T e3, T e4, T e5, T e6, T e7, T e8)
      Type Parameters:
      T -
      Parameters:
      e1 -
      e2 -
      e3 -
      e4 -
      e5 -
      e6 -
      e7 -
      e8 -
      Returns:
    • of

      public static <T> ImmutableArray<T> of(T e1, T e2, T e3, T e4, T e5, T e6, T e7, T e8, T e9)
      Type Parameters:
      T -
      Parameters:
      e1 -
      e2 -
      e3 -
      e4 -
      e5 -
      e6 -
      e7 -
      e8 -
      e9 -
      Returns:
    • of

      public static <T> ImmutableArray<T> of(T e1, T e2, T e3, T e4, T e5, T e6, T e7, T e8, T e9, T e10)
      Type Parameters:
      T -
      Parameters:
      e1 -
      e2 -
      e3 -
      e4 -
      e5 -
      e6 -
      e7 -
      e8 -
      e9 -
      e10 -
      Returns:
    • copyOf

      public static <T> ImmutableArray<T> copyOf(T[] elements)
      Type Parameters:
      T -
      Parameters:
      elements -
      Returns:
    • wrap

      @Deprecated @Beta public static <T> ImmutableArray<T> wrap(T[] elements)
      Deprecated.
      the ImmutableArray may be modified through the specified elements
      Wraps the provided array into an ImmutableArray. Changes to the specified array will be reflected in the ImmutableArray
      Type Parameters:
      T -
      Parameters:
      elements -
      Returns:
      an ImmutableArray backed by the specified elements
    • length

      public int length()
    • isEmpty

      public boolean isEmpty()
    • get

      public T get(int index)
      Parameters:
      index -
      Returns:
    • indexOf

      public int indexOf(T valueToFind)
      Parameters:
      valueToFind -
      Returns:
    • lastIndexOf

      public int lastIndexOf(T valueToFind)
      Parameters:
      valueToFind -
      Returns:
    • contains

      public boolean contains(T valueToFind)
      Parameters:
      valueToFind -
      Returns:
    • copy

      public ImmutableArray<T> copy(int fromIndex, int toIndex) throws IndexOutOfBoundsException
      Parameters:
      fromIndex -
      toIndex -
      Returns:
      Throws:
      IndexOutOfBoundsException
    • asList

      public ImmutableList<T> asList()
    • iterator

      public ObjIterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • stream

      public Stream<T> stream()
    • forEach

      public void forEach(Consumer<? super T> consumer) throws IllegalArgumentException
      Specified by:
      forEach in interface Iterable<T>
      Parameters:
      consumer -
      Throws:
      IllegalArgumentException
    • foreach

      @Beta public <E extends Exception> void foreach(Throwables.Consumer<? super T,E> consumer) throws IllegalArgumentException, E
      Type Parameters:
      E -
      Parameters:
      consumer -
      Throws:
      IllegalArgumentException
      E
    • foreachIndexed

      @Beta public <E extends Exception> void foreachIndexed(Throwables.IntObjConsumer<? super T,E> consumer) throws IllegalArgumentException, E
      Type Parameters:
      E -
      Parameters:
      consumer -
      Throws:
      IllegalArgumentException
      E
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      Parameters:
      obj -
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object