Package com.oracle.truffle.api
Class ArrayUtils
java.lang.Object
com.oracle.truffle.api.ArrayUtils
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 TypeMethodDescriptionstatic int
indexOf
(byte[] array, int fromIndex, int maxIndex, byte... values) Returns the index of the first occurrence of any byte contained invalues
inarray
, bounded byfromIndex
(inclusive) andmaxIndex
(exclusive).static int
indexOf
(char[] array, int fromIndex, int maxIndex, char... values) Returns the index of the first occurrence of any character contained invalues
inarray
, bounded byfromIndex
(inclusive) andmaxIndex
(exclusive).static int
Returns the index of the first occurrence of any character contained invalues
instring
, bounded byfromIndex
(inclusive) andmaxIndex
(exclusive).static int
indexOfWithOrMask
(byte[] haystack, int fromIndex, int length, byte[] needle, byte[] mask) Returns the index of the first region ofhaystack
that equalsneedle
after being OR'ed withmask
, bounded byfromIndex
(inclusive) andlength
.static int
indexOfWithOrMask
(char[] haystack, int fromIndex, int length, char[] needle, char[] mask) Returns the index of the first region ofhaystack
that equalsneedle
after being OR'ed withmask
, bounded byfromIndex
(inclusive) andlength
.static int
indexOfWithOrMask
(String haystack, int fromIndex, int length, String needle, String mask) Returns the index of the first region ofhaystack
that equalsneedle
after being OR'ed withmask
, bounded byfromIndex
(inclusive) andlength
.static boolean
regionEqualsWithOrMask
(byte[] a, int offsetA, byte[] b, int offsetB, int length, byte[] mask) Returnstrue
iff for all indicesi
from0
(inclusive) tolength
(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) Returnstrue
iff for all indicesi
from0
(inclusive) tolength
(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) Returnstrue
iff for all indicesi
from0
(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 invalues
instring
, bounded byfromIndex
(inclusive) andmaxIndex
(exclusive).- Returns:
- the index of the first occurrence of any character contained in
values
instring
that is greater than or equal tofromIndex
and less thanmaxIndex
, 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 invalues
inarray
, bounded byfromIndex
(inclusive) andmaxIndex
(exclusive).- Returns:
- the index of the first occurrence of any character contained in
values
inarray
that is greater than or equal tofromIndex
and less thanmaxIndex
, 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 invalues
inarray
, bounded byfromIndex
(inclusive) andmaxIndex
(exclusive).- Returns:
- the index of the first occurrence of any byte contained in
values
inarray
that is greater than or equal tofromIndex
and less thanmaxIndex
, 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 ofhaystack
that equalsneedle
after being OR'ed withmask
, bounded byfromIndex
(inclusive) andlength
. Performs best ifneedle
andmask
areCompilerDirectives.CompilationFinal
withdimensions = 1
.- Returns:
- the index of the first region of
haystack
where for all indicesi
ofneedle
(haystack[index + i] | mask[i]) == needle[i]
holds, andfromIndex <= 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 ofhaystack
that equalsneedle
after being OR'ed withmask
, bounded byfromIndex
(inclusive) andlength
. Performs best ifneedle
andmask
areCompilerDirectives.CompilationFinal
withdimensions = 1
.- Returns:
- the index of the first region of
haystack
where for all indicesi
ofneedle
(haystack[index + i] | mask[i]) == needle[i]
holds, andfromIndex <= 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 ofhaystack
that equalsneedle
after being OR'ed withmask
, bounded byfromIndex
(inclusive) andlength
. Performs best ifneedle
andmask
areCompilerDirectives.CompilationFinal
.- Returns:
- the index of the first region of
haystack
where for all indicesi
ofneedle
(haystack.charAt(index + i) | mask.charAt(i)) == needle.charAt(i)
holds, andfromIndex <= 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) Returnstrue
iff for all indicesi
from0
(inclusive) tolength
(exclusive),(a[offsetA + i] | mask[i]) == b[offsetB + i]
holds. Performs best iflength
andmask
areCompilerDirectives.CompilationFinal
withdimensions = 1
. Ifmask
isnull
, 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) Returnstrue
iff for all indicesi
from0
(inclusive) tolength
(exclusive),(a[offsetA + i] | mask[i]) == b[offsetB + i]
holds. Performs best iflength
andmask
areCompilerDirectives.CompilationFinal
withdimensions = 1
. Ifmask
isnull
, 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) Returnstrue
iff for all indicesi
from0
(inclusive) tolength
(exclusive),(a.charAt(offsetA + i) | mask.charAt(i)) == b.charAt(offsetB + i)
holds. Performs best iflength
andmask
areCompilerDirectives.CompilationFinal
withdimensions = 1
. Ifmask
isnull
, it is treated as if it was filled with zeroes.- Since:
- 19.3
-