Class ArrayExtensions

java.lang.Object
org.eclipse.xtext.xbase.lib.ArrayExtensions

@GwtCompatible public class ArrayExtensions extends Object
An extension library for arrays, to be used with Xtend. It allows to use an array without converting it to a list first.
Since:
2.4
Author:
Sven Efftinge - Initial contribution and API, Stephane Galland - Add operations on 2-dimension arrays.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean[]
    clone(boolean[] array)
    Clones the array.
    static byte[]
    clone(byte[] array)
    Clones the array.
    static char[]
    clone(char[] array)
    Clones the array.
    static double[]
    clone(double[] array)
    Clones the array.
    static float[]
    clone(float[] array)
    Clones the array.
    static int[]
    clone(int[] array)
    Clones the array.
    static long[]
    clone(long[] array)
    Clones the array.
    static short[]
    clone(short[] array)
    Clones the array.
    static <T> T[]
    clone(T[] array)
    Clones the array.
    static boolean
    contains(boolean[] array, boolean value)
    Returns whether the array contains the given value.
    static boolean
    contains(byte[] array, byte value)
    Returns whether the array contains the given value.
    static boolean
    contains(char[] array, char value)
    Returns whether the array contains the given value.
    static boolean
    contains(double[] array, double value)
    Returns whether the array contains the given value.
    static boolean
    contains(float[] array, float value)
    Returns whether the array contains the given value.
    static boolean
    contains(int[] array, int value)
    Returns whether the array contains the given value.
    static boolean
    contains(long[] array, long value)
    Returns whether the array contains the given value.
    static boolean
    contains(short[] array, short value)
    Returns whether the array contains the given value.
    static boolean
    contains(Object[] array, Object o)
    Returns whether the array contains the given element.
    static boolean
    equals(boolean[] array, Object other)
    Returns whether the array and the given other object are identical.
    static boolean
    equals(byte[] array, Object other)
    Returns whether the array and the given other object are identical.
    static boolean
    equals(char[] array, Object other)
    Returns whether the array and the given other object are identical.
    static boolean
    equals(double[] array, Object other)
    Returns whether the array and the given other object are identical.
    static boolean
    equals(float[] array, Object other)
    Returns whether the array and the given other object are identical.
    static boolean
    equals(int[] array, Object other)
    Returns whether the array and the given other object are identical.
    static boolean
    equals(long[] array, Object other)
    Returns whether the array and the given other object are identical.
    static boolean
    equals(short[] array, Object other)
    Returns whether the array and the given other object are identical.
    static boolean
    equals(Object[] array, Object other)
    Returns whether the array and the given other object are identical.
    static boolean
    get(boolean[][] array, int index0, int index1)
     
    static boolean
    get(boolean[] array, int index)
     
    static byte
    get(byte[][] array, int index0, int index1)
     
    static byte
    get(byte[] array, int index)
     
    static char
    get(char[][] array, int index0, int index1)
     
    static char
    get(char[] array, int index)
     
    static double
    get(double[][] array, int index0, int index1)
     
    static double
    get(double[] array, int index)
     
    static float
    get(float[][] array, int index0, int index1)
     
    static float
    get(float[] array, int index)
     
    static int
    get(int[][] array, int index0, int index1)
     
    static int
    get(int[] array, int index)
     
    static long
    get(long[][] array, int index0, int index1)
     
    static long
    get(long[] array, int index)
     
    static short
    get(short[][] array, int index0, int index1)
     
    static short
    get(short[] array, int index)
     
    static <T> T
    get(T[][] array, int index0, int index1)
     
    static <T> T
    get(T[] array, int index)
     
    static int
    hashCode(boolean[] array)
    Returns a hash code value for the given array.
    static int
    hashCode(byte[] array)
    Returns a hash code value for the given array.
    static int
    hashCode(char[] array)
    Returns a hash code value for the given array.
    static int
    hashCode(double[] array)
    Returns a hash code value for the given array.
    static int
    hashCode(float[] array)
    Returns a hash code value for the given array.
    static int
    hashCode(int[] array)
    Returns a hash code value for the given array.
    static int
    hashCode(long[] array)
    Returns a hash code value for the given array.
    static int
    hashCode(short[] array)
    Returns a hash code value for the given array.
    static int
    hashCode(Object[] array)
    Returns a hash code value for the given array.
    static int
    length(boolean[] array)
     
    static int
    length(byte[] array)
     
    static int
    length(char[] array)
     
    static int
    length(double[] array)
     
    static int
    length(float[] array)
     
    static int
    length(int[] array)
     
    static int
    length(long[] array)
     
    static int
    length(short[] array)
     
    static int
    length(Object[] array)
     
    static boolean
    set(boolean[][] array, int index0, int index1, boolean value)
     
    static boolean
    set(boolean[] array, int index, boolean value)
     
    static byte
    set(byte[][] array, int index0, int index1, byte value)
     
    static byte
    set(byte[] array, int index, byte value)
     
    static char
    set(char[][] array, int index0, int index1, char value)
     
    static char
    set(char[] array, int index, char value)
     
    static double
    set(double[][] array, int index0, int index1, double value)
     
    static double
    set(double[] array, int index, double value)
     
    static float
    set(float[][] array, int index0, int index1, float value)
     
    static float
    set(float[] array, int index, float value)
     
    static int
    set(int[][] array, int index0, int index1, int value)
     
    static int
    set(int[] array, int index, int value)
     
    static long
    set(long[][] array, int index0, int index1, long value)
     
    static long
    set(long[] array, int index, long value)
     
    static short
    set(short[][] array, int index0, int index1, short value)
     
    static short
    set(short[] array, int index, short value)
     
    static <T, E extends T>
    T
    set(T[][] array, int index0, int index1, E value)
     
    static <T, E extends T>
    T
    set(T[] array, int index, E value)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ArrayExtensions

      public ArrayExtensions()
  • Method Details

    • set

      public static <T, E extends T> T set(T[] array, int index, E value)
      Parameters:
      array - the array
      index - the index the value should be set at
      value - the value to set at the given index
      Returns:
      the new value
      Since:
      2.4
    • get

      @Pure public static <T> T get(T[] array, int index)
      Parameters:
      array - the array
      index - the index
      Returns:
      the value at the given index
    • clone

      @Pure @GwtIncompatible("clone") public static <T> T[] clone(T[] array)
      Clones the array. @see Object.clone()
      Parameters:
      array - the array
      Returns:
      the cloned array
      Since:
      2.5
    • length

      @Pure public static int length(Object[] array)
      Parameters:
      array - the array
      Returns:
      the length of the given array
    • hashCode

      @Pure public static int hashCode(Object[] array)
      Returns a hash code value for the given array.
      Parameters:
      array - the array
      Returns:
      the hash code
      Since:
      2.5
    • equals

      @Pure public static boolean equals(Object[] array, Object other)
      Returns whether the array and the given other object are identical. Delegates to Object.equals(Object)
      Parameters:
      array - the array
      other - the other element to compare to
      Returns:
      whether the two given argument are identical
      Since:
      2.5
    • contains

      @Pure public static boolean contains(Object[] array, Object o)
      Returns whether the array contains the given element. More formally, returns true if and only if this array contains at least one element e such that (o==null ? e==null : o.equals(e)).
      Parameters:
      array - the array to test
      o - element whose presence in this array is to be tested
      Returns:
      true if this array contains the specified element
    • get

      @Pure public static boolean get(boolean[] array, int index)
      Parameters:
      array - the array
      index - the index
      Returns:
      the value at the given index
    • set

      public static boolean set(boolean[] array, int index, boolean value)
      Parameters:
      array - the array
      index - the index the value should be set at
      value - the value to set at the given index
      Returns:
      the new value
    • length

      @Pure public static int length(boolean[] array)
      Parameters:
      array - the array
      Returns:
      the length of the given array
    • hashCode

      @Pure public static int hashCode(boolean[] array)
      Returns a hash code value for the given array.
      Parameters:
      array - the array
      Returns:
      the hash code
      Since:
      2.5
    • equals

      @Pure public static boolean equals(boolean[] array, Object other)
      Returns whether the array and the given other object are identical. Delegates to Object.equals(Object)
      Parameters:
      array - the array
      other - the other element to compare to
      Returns:
      whether the two given argument are identical
      Since:
      2.5
    • clone

      @Pure @GwtIncompatible("clone") public static boolean[] clone(boolean[] array)
      Clones the array. @see Object.clone()
      Parameters:
      array - the array
      Returns:
      the cloned array
      Since:
      2.5
    • contains

      @Pure public static boolean contains(boolean[] array, boolean value)
      Returns whether the array contains the given value. More formally, returns true if and only if this array contains at least one element e such that value==e.
      Parameters:
      array - the array to test
      value - value whose presence in this array is to be tested
      Returns:
      true if this array contains the specified element
    • get

      @Pure public static double get(double[] array, int index)
      Parameters:
      array - the array
      index - the index
      Returns:
      the value at the given index
    • set

      public static double set(double[] array, int index, double value)
      Parameters:
      array - the array
      index - the index the value should be set at
      value - the value to set at the given index
      Returns:
      the new value
    • length

      @Pure public static int length(double[] array)
      Parameters:
      array - the array
      Returns:
      the length of the given array
    • hashCode

      @Pure public static int hashCode(double[] array)
      Returns a hash code value for the given array.
      Parameters:
      array - the array
      Returns:
      the hash code
      Since:
      2.5
    • equals

      @Pure public static boolean equals(double[] array, Object other)
      Returns whether the array and the given other object are identical. Delegates to Object.equals(Object)
      Parameters:
      array - the array
      other - the other element to compare to
      Returns:
      whether the two given argument are identical
      Since:
      2.5
    • clone

      @Pure @GwtIncompatible("clone") public static double[] clone(double[] array)
      Clones the array. @see Object.clone()
      Parameters:
      array - the array
      Returns:
      the cloned array
      Since:
      2.5
    • contains

      @Pure public static boolean contains(double[] array, double value)
      Returns whether the array contains the given value. More formally, returns true if and only if this array contains at least one element e such that java.lang.Double.compare(o, e) == 0).
      Parameters:
      array - the array to test
      value - value whose presence in this array is to be tested
      Returns:
      true if this array contains the specified element
    • get

      @Pure public static float get(float[] array, int index)
      Parameters:
      array - the array
      index - the index
      Returns:
      the value at the given index
    • set

      public static float set(float[] array, int index, float value)
      Parameters:
      array - the array
      index - the index the value should be set at
      value - the value to set at the given index
      Returns:
      the new value
    • length

      @Pure public static int length(float[] array)
      Parameters:
      array - the array
      Returns:
      the length of the given array
    • hashCode

      @Pure public static int hashCode(float[] array)
      Returns a hash code value for the given array.
      Parameters:
      array - the array
      Returns:
      the hash code
      Since:
      2.5
    • equals

      @Pure public static boolean equals(float[] array, Object other)
      Returns whether the array and the given other object are identical. Delegates to Object.equals(Object)
      Parameters:
      array - the array
      other - the other element to compare to
      Returns:
      whether the two given argument are identical
      Since:
      2.5
    • clone

      @Pure @GwtIncompatible("clone") public static float[] clone(float[] array)
      Clones the array. @see Object.clone()
      Parameters:
      array - the array
      Returns:
      the cloned array
      Since:
      2.5
    • contains

      @Pure public static boolean contains(float[] array, float value)
      Returns whether the array contains the given value. More formally, returns true if and only if this array contains at least one element e such that java.lang.Float.compare(o, e) == 0).
      Parameters:
      array - the array to test
      value - value whose presence in this array is to be tested
      Returns:
      true if this array contains the specified element
    • get

      @Pure public static long get(long[] array, int index)
      Parameters:
      array - the array
      index - the index
      Returns:
      the value at the given index
    • set

      public static long set(long[] array, int index, long value)
      Parameters:
      array - the array
      index - the index the value should be set at
      value - the value to set at the given index
      Returns:
      the new value
    • length

      @Pure public static int length(long[] array)
      Parameters:
      array - the array
      Returns:
      the length of the given array
    • hashCode

      @Pure public static int hashCode(long[] array)
      Returns a hash code value for the given array.
      Parameters:
      array - the array
      Returns:
      the hash code
      Since:
      2.5
    • equals

      @Pure public static boolean equals(long[] array, Object other)
      Returns whether the array and the given other object are identical. Delegates to Object.equals(Object)
      Parameters:
      array - the array
      other - the other element to compare to
      Returns:
      whether the two given argument are identical
      Since:
      2.5
    • clone

      @Pure @GwtIncompatible("clone") public static long[] clone(long[] array)
      Clones the array. @see Object.clone()
      Parameters:
      array - the array
      Returns:
      the cloned array
      Since:
      2.5
    • contains

      @Pure public static boolean contains(long[] array, long value)
      Returns whether the array contains the given value. More formally, returns true if and only if this array contains at least one element e such that (value == e).
      Parameters:
      array - the array to test
      value - element whose presence in this array is to be tested
      Returns:
      true if this array contains the specified element
    • get

      @Pure public static int get(int[] array, int index)
      Parameters:
      array - the array
      index - the index
      Returns:
      the value at the given index
    • set

      public static int set(int[] array, int index, int value)
      Parameters:
      array - the array
      index - the index the value should be set at
      value - the value to set at the given index
      Returns:
      the new value
    • length

      @Pure public static int length(int[] array)
      Parameters:
      array - the array
      Returns:
      the length of the given array
    • hashCode

      @Pure public static int hashCode(int[] array)
      Returns a hash code value for the given array.
      Parameters:
      array - the array
      Returns:
      the hash code
      Since:
      2.5
    • equals

      @Pure public static boolean equals(int[] array, Object other)
      Returns whether the array and the given other object are identical. Delegates to Object.equals(Object)
      Parameters:
      array - the array
      other - the other element to compare to
      Returns:
      whether the two given argument are identical
      Since:
      2.5
    • clone

      @Pure @GwtIncompatible("clone") public static int[] clone(int[] array)
      Clones the array. @see Object.clone()
      Parameters:
      array - the array
      Returns:
      the cloned array
      Since:
      2.5
    • contains

      @Pure public static boolean contains(int[] array, int value)
      Returns whether the array contains the given value. More formally, returns true if and only if this array contains at least one element e such that (value == e).
      Parameters:
      array - the array to test
      value - value whose presence in this array is to be tested
      Returns:
      true if this array contains the specified element
    • get

      @Pure public static char get(char[] array, int index)
      Parameters:
      array - the array
      index - the index
      Returns:
      the value at the given index
    • set

      public static char set(char[] array, int index, char value)
      Parameters:
      array - the array
      index - the index the value should be set at
      value - the value to set at the given index
      Returns:
      the new value
    • length

      @Pure public static int length(char[] array)
      Parameters:
      array - the array
      Returns:
      the length of the given array
    • hashCode

      @Pure public static int hashCode(char[] array)
      Returns a hash code value for the given array.
      Parameters:
      array - the array
      Returns:
      the hash code
      Since:
      2.5
    • equals

      @Pure public static boolean equals(char[] array, Object other)
      Returns whether the array and the given other object are identical. Delegates to Object.equals(Object)
      Parameters:
      array - the array
      other - the other element to compare to
      Returns:
      whether the two given argument are identical
      Since:
      2.5
    • clone

      @Pure @GwtIncompatible("clone") public static char[] clone(char[] array)
      Clones the array. @see Object.clone()
      Parameters:
      array - the array
      Returns:
      the cloned array
      Since:
      2.5
    • contains

      @Pure public static boolean contains(char[] array, char value)
      Returns whether the array contains the given value. More formally, returns true if and only if this array contains at least one element e such that (value == e).
      Parameters:
      array - the array to test
      value - value whose presence in this array is to be tested
      Returns:
      true if this array contains the specified element
    • get

      @Pure public static short get(short[] array, int index)
      Parameters:
      array - the array
      index - the index
      Returns:
      the value at the given index
    • set

      public static short set(short[] array, int index, short value)
      Parameters:
      array - the array
      index - the index the value should be set at
      value - the value to set at the given index
      Returns:
      the new value
    • length

      @Pure public static int length(short[] array)
      Parameters:
      array - the array
      Returns:
      the length of the given array
    • hashCode

      @Pure public static int hashCode(short[] array)
      Returns a hash code value for the given array.
      Parameters:
      array - the array
      Returns:
      the hash code
      Since:
      2.5
    • equals

      @Pure public static boolean equals(short[] array, Object other)
      Returns whether the array and the given other object are identical. Delegates to Object.equals(Object)
      Parameters:
      array - the array
      other - the other element to compare to
      Returns:
      whether the two given argument are identical
      Since:
      2.5
    • clone

      @Pure @GwtIncompatible("clone") public static short[] clone(short[] array)
      Clones the array. @see Object.clone()
      Parameters:
      array - the array
      Returns:
      the cloned array
      Since:
      2.5
    • contains

      @Pure public static boolean contains(short[] array, short value)
      Returns whether the array contains the given value. More formally, returns true if and only if this array contains at least one element e such that (value == e).
      Parameters:
      array - the array to test
      value - value whose presence in this array is to be tested
      Returns:
      true if this array contains the specified element
    • get

      @Pure public static byte get(byte[] array, int index)
      Parameters:
      array - the array
      index - the index
      Returns:
      the value at the given index
    • set

      public static byte set(byte[] array, int index, byte value)
      Parameters:
      array - the array
      index - the index the value should be set at
      value - the value to set at the given index
      Returns:
      the new value
    • length

      @Pure public static int length(byte[] array)
      Parameters:
      array - the array
      Returns:
      the length of the given array
    • hashCode

      @Pure public static int hashCode(byte[] array)
      Returns a hash code value for the given array.
      Parameters:
      array - the array
      Returns:
      the hash code
      Since:
      2.5
    • equals

      @Pure public static boolean equals(byte[] array, Object other)
      Returns whether the array and the given other object are identical. Delegates to Object.equals(Object)
      Parameters:
      array - the array
      other - the other element to compare to
      Returns:
      whether the two given argument are identical
      Since:
      2.5
    • clone

      @Pure @GwtIncompatible("clone") public static byte[] clone(byte[] array)
      Clones the array. @see Object.clone()
      Parameters:
      array - the array
      Returns:
      the cloned array
      Since:
      2.5
    • contains

      @Pure public static boolean contains(byte[] array, byte value)
      Returns whether the array contains the given value. More formally, returns true if and only if this array contains at least one element e such that (value == e).
      Parameters:
      array - the array to test
      value - value whose presence in this array is to be tested
      Returns:
      true if this array contains the specified element
    • get

      @Pure public static <T> T get(T[][] array, int index0, int index1)
      Parameters:
      array - the array
      index0 - the first index
      index1 - the second index
      Returns:
      the value at the given index
      Since:
      2.16
    • set

      public static <T, E extends T> T set(T[][] array, int index0, int index1, E value)
      Parameters:
      array - the array
      index0 - the first index the value should be set at
      index1 - the second index the value should be set at
      value - the value to set at the given indexes
      Returns:
      the new value
      Since:
      2.16
    • get

      @Pure public static boolean get(boolean[][] array, int index0, int index1)
      Parameters:
      array - the array
      index0 - the first index
      index1 - the second index
      Returns:
      the value at the given indexes
      Since:
      2.16
    • set

      public static boolean set(boolean[][] array, int index0, int index1, boolean value)
      Parameters:
      array - the array
      index0 - the first index the value should be set at
      index1 - the second index the value should be set at
      value - the value to set at the given indexes
      Returns:
      the new value
      Since:
      2.16
    • get

      @Pure public static double get(double[][] array, int index0, int index1)
      Parameters:
      array - the array
      index0 - the first index
      index1 - the second index
      Returns:
      the value at the given indexes
      Since:
      2.16
    • set

      public static double set(double[][] array, int index0, int index1, double value)
      Parameters:
      array - the array
      index0 - the first index the value should be set at
      index1 - the second index the value should be set at
      value - the value to set at the given indexex
      Returns:
      the new value
      Since:
      2.16
    • get

      @Pure public static float get(float[][] array, int index0, int index1)
      Parameters:
      array - the array
      index0 - the first index
      index1 - the first index
      Returns:
      the value at the given indexes
      Since:
      2.16
    • set

      public static float set(float[][] array, int index0, int index1, float value)
      Parameters:
      array - the array
      index0 - the first index the value should be set at
      index1 - the second index the value should be set at
      value - the value to set at the given indexes
      Returns:
      the new value
      Since:
      2.16
    • get

      @Pure public static long get(long[][] array, int index0, int index1)
      Parameters:
      array - the array
      index0 - the first index
      index1 - the second index
      Returns:
      the value at the given indexes
      Since:
      2.16
    • set

      public static long set(long[][] array, int index0, int index1, long value)
      Parameters:
      array - the array
      index0 - the first index the value should be set at
      index1 - the second index the value should be set at
      value - the value to set at the given indexes
      Returns:
      the new value
      Since:
      2.16
    • get

      @Pure public static int get(int[][] array, int index0, int index1)
      Parameters:
      array - the array
      index0 - the first index
      index1 - the second index
      Returns:
      the value at the given indexes
      Since:
      2.16
    • set

      public static int set(int[][] array, int index0, int index1, int value)
      Parameters:
      array - the array
      index0 - the first index the value should be set at
      index1 - the second index the value should be set at
      value - the value to set at the given index
      Returns:
      the new value
      Since:
      2.16
    • get

      @Pure public static char get(char[][] array, int index0, int index1)
      Parameters:
      array - the array
      index0 - the first index
      index1 - the second index
      Returns:
      the value at the given indexes
      Since:
      2.16
    • set

      public static char set(char[][] array, int index0, int index1, char value)
      Parameters:
      array - the array
      index0 - the first index the value should be set at
      index1 - the second index the value should be set at
      value - the value to set at the given indexes
      Returns:
      the new value
      Since:
      2.16
    • get

      @Pure public static short get(short[][] array, int index0, int index1)
      Parameters:
      array - the array
      index0 - the first index
      index1 - the second index
      Returns:
      the value at the given indexes
      Since:
      2.16
    • set

      public static short set(short[][] array, int index0, int index1, short value)
      Parameters:
      array - the array
      index0 - the first index the value should be set at
      index1 - the second index the value should be set at
      value - the value to set at the given indexes
      Returns:
      the new value
      Since:
      2.16
    • get

      @Pure public static byte get(byte[][] array, int index0, int index1)
      Parameters:
      array - the array
      index0 - the first index
      index1 - the second index
      Returns:
      the value at the given indexes
      Since:
      2.16
    • set

      public static byte set(byte[][] array, int index0, int index1, byte value)
      Parameters:
      array - the array
      index0 - the first index the value should be set at
      index1 - the second index the value should be set at
      value - the value to set at the given indexes
      Returns:
      the new value
      Since:
      2.16