Package org.stianloader.mrjmania
Class MRJArrays
java.lang.Object
org.stianloader.mrjmania.MRJArrays
Polyfills for array-related methods.
Mostly methods that are/should be in the Arrays class.
-
Method Summary
Modifier and TypeMethodDescriptionstatic final booleanequals(byte @NotNull [] a, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int aFromIndex, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int aToIndex, byte @NotNull [] b, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int bFromIndex, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int bToIndex) Assert that the two array sections, which should be of equal length, are equal to each other in content.static final @org.jetbrains.annotations.Range(from=-1L, to=2147483647L) intmismatch(byte @NotNull [] a, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int aFromIndex, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int aToIndex, byte @NotNull [] b, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int bFromIndex, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int bToIndex) Return the index where the two arrays first converge between each other in a given interval.static final @org.jetbrains.annotations.Range(from=-1L, to=2147483647L) intmismatch(byte @NotNull [] a, byte @NotNull [] b) Return the index where the two arrays first diverge from each other.
-
Method Details
-
equals
@Contract(pure=true) public static final boolean equals(byte @NotNull [] a, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int aFromIndex, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int aToIndex, byte @NotNull [] b, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int bFromIndex, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int bToIndex) Assert that the two array sections, which should be of equal length, are equal to each other in content.- Parameters:
a- The arrayaaFromIndex- The first index in arrayaof the section for that arrayaToIndex- The last index in arrayaof the section for that arrayb- The arraybbFromIndex- The first index in arraybof the section for that arraybToIndex- The last index in arraybof the section for that array- Returns:
trueif the array section contents are equal,falseotherwise.
-
mismatch
@Contract(pure=true) public static final @org.jetbrains.annotations.Range(from=-1L, to=2147483647L) int mismatch(byte @NotNull [] a, byte @NotNull [] b) Return the index where the two arrays first diverge from each other.If the arrays do not diverge (i.e. are equal to each),
-1is returned.- Parameters:
a- The arrayab- The arrayb- Returns:
- The index where the two arrays first converge between each other, or
-1if the two arrays are equal.
-
mismatch
@Contract(pure=true) public static final @org.jetbrains.annotations.Range(from=-1L, to=2147483647L) int mismatch(byte @NotNull [] a, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int aFromIndex, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int aToIndex, byte @NotNull [] b, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int bFromIndex, @org.jetbrains.annotations.Range(from=0L, to=2147483647L) int bToIndex) Return the index where the two arrays first converge between each other in a given interval.If the length of the two array sections don't match, then the two arrays are not considered equal and the length of the smallest section is returned, provided there isn't an earlier mismatch.
If the array sections do not diverge and are of equal length (i.e. are equal to each), then
-1is returned.The returned value is in relative to aFromIndex/bFromIndex! As such, it will never be larger than either value.
- Parameters:
a- The arrayaaFromIndex- The first index in arrayaof the section for that arrayaToIndex- The last index in arrayaof the section for that arrayb- The arraybbFromIndex- The first index in arraybof the section for that arraybToIndex- The last index in arraybof the section for that array- Returns:
- The index of the first mismatch, relative from aFromIndex/bFromIndex.
-