Class ArrayUtils
java.lang.Object
com.oracle.truffle.api.ArrayUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidarraycopy(int[] source, int sourceIndex, int[] destination, int destinationIndex, int length) Copieslengthelements fromsource, starting atsourceIndex, todestination, starting atdestinationIndex.static intindexOf(byte[] array, int fromIndex, int maxIndex, byte... values) Returns the index of the first occurrence of any byte contained invaluesinarray, bounded byfromIndex(inclusive) andmaxIndex(exclusive).static intindexOf(char[] array, int fromIndex, int maxIndex, char... values) Returns the index of the first occurrence of any character contained invaluesinarray, bounded byfromIndex(inclusive) andmaxIndex(exclusive).static intReturns the index of the first occurrence of any character contained invaluesinstring, bounded byfromIndex(inclusive) andmaxIndex(exclusive).static intindexOfWithOrMask(byte[] haystack, int fromIndex, int length, byte[] needle, byte[] mask) Returns the index of the first region ofhaystackthat equalsneedleafter being OR'ed withmask, bounded byfromIndex(inclusive) andlength.static intindexOfWithOrMask(char[] haystack, int fromIndex, int length, char[] needle, char[] mask) Returns the index of the first region ofhaystackthat equalsneedleafter being OR'ed withmask, bounded byfromIndex(inclusive) andlength.static intindexOfWithOrMask(String haystack, int fromIndex, int length, String needle, String mask) Returns the index of the first region ofhaystackthat equalsneedleafter being OR'ed withmask, bounded byfromIndex(inclusive) andlength.static booleanregionEqualsWithOrMask(byte[] a, int offsetA, byte[] b, int offsetB, int length, byte[] mask) Returnstrueiff for all indicesifrom0(inclusive) tolength(exclusive),(a[offsetA + i] | mask[i]) == b[offsetB + i]holds.static booleanregionEqualsWithOrMask(char[] a, int offsetA, char[] b, int offsetB, int length, char[] mask) Returnstrueiff for all indicesifrom0(inclusive) tolength(exclusive),(a[offsetA + i] | mask[i]) == b[offsetB + i]holds.static booleanregionEqualsWithOrMask(String a, int offsetA, String b, int offsetB, int length, String mask) Returnstrueiff for all indicesifrom0(inclusive) tolength(exclusive),(a.charAt(offsetA + i) | mask.charAt(i)) == b.charAt(offsetB + i)holds.
-
Method Details
-
indexOf
Returns the index of the first occurrence of any character contained invaluesinstring, bounded byfromIndex(inclusive) andmaxIndex(exclusive).- Returns:
- the index of the first occurrence of any character contained in
valuesinstringthat is greater than or equal tofromIndexand less thanmaxIndex, or-1if 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 invaluesinarray, bounded byfromIndex(inclusive) andmaxIndex(exclusive).- Returns:
- the index of the first occurrence of any character contained in
valuesinarraythat is greater than or equal tofromIndexand less thanmaxIndex, or-1if 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 invaluesinarray, bounded byfromIndex(inclusive) andmaxIndex(exclusive).- Returns:
- the index of the first occurrence of any byte contained in
valuesinarraythat is greater than or equal tofromIndexand less thanmaxIndex, or-1if 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 ofhaystackthat equalsneedleafter being OR'ed withmask, bounded byfromIndex(inclusive) andlength. Performs best ifneedleandmaskareCompilerDirectives.CompilationFinalwithdimensions = 1.- Returns:
- the index of the first region of
haystackwhere for all indicesiofneedle(haystack[index + i] | mask[i]) == needle[i]holds, andfromIndex <= index && index + needle.length <= fromIndex + lengthholds, or-1if 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 ofhaystackthat equalsneedleafter being OR'ed withmask, bounded byfromIndex(inclusive) andlength. Performs best ifneedleandmaskareCompilerDirectives.CompilationFinalwithdimensions = 1.- Returns:
- the index of the first region of
haystackwhere for all indicesiofneedle(haystack[index + i] | mask[i]) == needle[i]holds, andfromIndex <= index && index + needle.length <= fromIndex + lengthholds, or-1if 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 ofhaystackthat equalsneedleafter being OR'ed withmask, bounded byfromIndex(inclusive) andlength. Performs best ifneedleandmaskareCompilerDirectives.CompilationFinal.- Returns:
- the index of the first region of
haystackwhere for all indicesiofneedle(haystack.charAt(index + i) | mask.charAt(i)) == needle.charAt(i)holds, andfromIndex <= index && index + needle.length() <= fromIndex + lengthholds, or-1if 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) Returnstrueiff for all indicesifrom0(inclusive) tolength(exclusive),(a[offsetA + i] | mask[i]) == b[offsetB + i]holds. Performs best iflengthandmaskareCompilerDirectives.CompilationFinalwithdimensions = 1. Ifmaskisnull, 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) Returnstrueiff for all indicesifrom0(inclusive) tolength(exclusive),(a[offsetA + i] | mask[i]) == b[offsetB + i]holds. Performs best iflengthandmaskareCompilerDirectives.CompilationFinalwithdimensions = 1. Ifmaskisnull, 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) Returnstrueiff for all indicesifrom0(inclusive) tolength(exclusive),(a.charAt(offsetA + i) | mask.charAt(i)) == b.charAt(offsetB + i)holds. Performs best iflengthandmaskareCompilerDirectives.CompilationFinalwithdimensions = 1. Ifmaskisnull, it is treated as if it was filled with zeroes.- Since:
- 19.3
-
arraycopy
public static void arraycopy(int[] source, int sourceIndex, int[] destination, int destinationIndex, int length) Copieslengthelements fromsource, starting atsourceIndex, todestination, starting atdestinationIndex.This method is intended for performance-sensitive Truffle code that copies non-overlapping
int[]regions and can benefit from compiler intrinsification, in particular for small constant-length copies. It is not a general replacement forSystem.arraycopy(Object, int, Object, int, int): useSystem.arraycopy(Object, int, Object, int, int)unless the stricter contract below is acceptable.Unlike
System.arraycopy(Object, int, Object, int, int), this method is intrinsified in a manner that doesn't behave exactly as the scalar loop would: overlapping source and destination regions are not supported, and individual elements may be copied twice, which may be observable in multi-threading contexts.- Since:
- 25.1
-