Class ArrayUtils

java.lang.Object
com.oracle.truffle.api.ArrayUtils

public final class ArrayUtils extends Object
This class provides additional operations for String as well as character and byte arrays, which may be intrinsified by a compiler.
Since:
19.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    indexOf(byte[] array, int fromIndex, int maxIndex, byte... values)
    Returns the index of the first occurrence of any byte contained in values in array, bounded by fromIndex (inclusive) and maxIndex (exclusive).
    static int
    indexOf(char[] array, int fromIndex, int maxIndex, char... values)
    Returns the index of the first occurrence of any character contained in values in array, bounded by fromIndex (inclusive) and maxIndex (exclusive).
    static int
    indexOf(String string, int fromIndex, int maxIndex, char... values)
    Returns the index of the first occurrence of any character contained in values in string, bounded by fromIndex (inclusive) and maxIndex (exclusive).
    static int
    indexOfWithOrMask(byte[] haystack, int fromIndex, int length, byte[] needle, byte[] mask)
    Returns the index of the first region of haystack that equals needle after being OR'ed with mask, bounded by fromIndex (inclusive) and length.
    static int
    indexOfWithOrMask(char[] haystack, int fromIndex, int length, char[] needle, char[] mask)
    Returns the index of the first region of haystack that equals needle after being OR'ed with mask, bounded by fromIndex (inclusive) and length.
    static int
    indexOfWithOrMask(String haystack, int fromIndex, int length, String needle, String mask)
    Returns the index of the first region of haystack that equals needle after being OR'ed with mask, bounded by fromIndex (inclusive) and length.
    static boolean
    regionEqualsWithOrMask(byte[] a, int offsetA, byte[] b, int offsetB, int length, byte[] mask)
    Returns true iff for all indices i from 0 (inclusive) to length (exclusive), (a[offsetA + i] | mask[i]) == b[offsetB + i] holds.
    static boolean
    regionEqualsWithOrMask(char[] a, int offsetA, char[] b, int offsetB, int length, char[] mask)
    Returns true iff for all indices i from 0 (inclusive) to length (exclusive), (a[offsetA + i] | mask[i]) == b[offsetB + i] holds.
    static boolean
    regionEqualsWithOrMask(String a, int offsetA, String b, int offsetB, int length, String mask)
    Returns true iff for all indices i from 0 (inclusive) to length (exclusive), (a.charAt(offsetA + i) | mask.charAt(i)) == b.charAt(offsetB + i) holds.

    Methods inherited from class java.lang.Object

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

    • indexOf

      public static int indexOf(String string, int fromIndex, int maxIndex, char... values)
      Returns the index of the first occurrence of any character contained in values in string, bounded by fromIndex (inclusive) and maxIndex (exclusive).
      Returns:
      the index of the first occurrence of any character contained in values in string that is greater than or equal to fromIndex and less than maxIndex, or -1 if none of the characters occur.
      Since:
      19.0
    • indexOf

      public static int indexOf(char[] array, int fromIndex, int maxIndex, char... values)
      Returns the index of the first occurrence of any character contained in values in array, bounded by fromIndex (inclusive) and maxIndex (exclusive).
      Returns:
      the index of the first occurrence of any character contained in values in array that is greater than or equal to fromIndex and less than maxIndex, or -1 if none of the characters occur.
      Since:
      19.0
    • indexOf

      public static int indexOf(byte[] array, int fromIndex, int maxIndex, byte... values)
      Returns the index of the first occurrence of any byte contained in values in array, bounded by fromIndex (inclusive) and maxIndex (exclusive).
      Returns:
      the index of the first occurrence of any byte contained in values in array that is greater than or equal to fromIndex and less than maxIndex, or -1 if none of the values occur.
      Since:
      19.0
    • indexOfWithOrMask

      public static int indexOfWithOrMask(byte[] haystack, int fromIndex, int length, byte[] needle, byte[] mask)
      Returns the index of the first region of haystack that equals needle after being OR'ed with mask, bounded by fromIndex (inclusive) and length. Performs best if needle and mask are CompilerDirectives.CompilationFinal with dimensions = 1.
      Returns:
      the index of the first region of haystack where for all indices i of needle (haystack[index + i] | mask[i]) == needle[i] holds, and fromIndex <= index && index + needle.length <= fromIndex + length holds, or -1 if no such region is found.
      Since:
      19.3
    • indexOfWithOrMask

      public static int indexOfWithOrMask(char[] haystack, int fromIndex, int length, char[] needle, char[] mask)
      Returns the index of the first region of haystack that equals needle after being OR'ed with mask, bounded by fromIndex (inclusive) and length. Performs best if needle and mask are CompilerDirectives.CompilationFinal with dimensions = 1.
      Returns:
      the index of the first region of haystack where for all indices i of needle (haystack[index + i] | mask[i]) == needle[i] holds, and fromIndex <= index && index + needle.length <= fromIndex + length holds, or -1 if no such region is found.
      Since:
      19.3
    • indexOfWithOrMask

      public static int indexOfWithOrMask(String haystack, int fromIndex, int length, String needle, String mask)
      Returns the index of the first region of haystack that equals needle after being OR'ed with mask, bounded by fromIndex (inclusive) and length. Performs best if needle and mask are CompilerDirectives.CompilationFinal.
      Returns:
      the index of the first region of haystack where for all indices i of needle (haystack.charAt(index + i) | mask.charAt(i)) == needle.charAt(i) holds, and fromIndex <= index && index + needle.length() <= fromIndex + length holds, or -1 if no such region is found.
      Since:
      19.3
    • regionEqualsWithOrMask

      public static boolean regionEqualsWithOrMask(byte[] a, int offsetA, byte[] b, int offsetB, int length, byte[] mask)
      Returns true iff for all indices i from 0 (inclusive) to length (exclusive), (a[offsetA + i] | mask[i]) == b[offsetB + i] holds. Performs best if length and mask are CompilerDirectives.CompilationFinal with dimensions = 1. If mask is null, it is treated as if it was filled with zeroes.
      Since:
      19.3
    • regionEqualsWithOrMask

      public static boolean regionEqualsWithOrMask(char[] a, int offsetA, char[] b, int offsetB, int length, char[] mask)
      Returns true iff for all indices i from 0 (inclusive) to length (exclusive), (a[offsetA + i] | mask[i]) == b[offsetB + i] holds. Performs best if length and mask are CompilerDirectives.CompilationFinal with dimensions = 1. If mask is null, it is treated as if it was filled with zeroes.
      Since:
      19.3
    • regionEqualsWithOrMask

      public static boolean regionEqualsWithOrMask(String a, int offsetA, String b, int offsetB, int length, String mask)
      Returns true iff for all indices i from 0 (inclusive) to length (exclusive), (a.charAt(offsetA + i) | mask.charAt(i)) == b.charAt(offsetB + i) holds. Performs best if length and mask are CompilerDirectives.CompilationFinal with dimensions = 1. If mask is null, it is treated as if it was filled with zeroes.
      Since:
      19.3