Class MRJArrays

java.lang.Object
org.stianloader.mrjmania.MRJArrays

public class MRJArrays extends Object
Polyfills for array-related methods.

Mostly methods that are/should be in the Arrays class.

  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 array a
      aFromIndex - The first index in array a of the section for that array
      aToIndex - The last index in array a of the section for that array
      b - The array b
      bFromIndex - The first index in array b of the section for that array
      bToIndex - The last index in array b of the section for that array
      Returns:
      true if the array section contents are equal, false otherwise.
    • 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), -1 is returned.

      Parameters:
      a - The array a
      b - The array b
      Returns:
      The index where the two arrays first converge between each other, or -1 if 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 -1 is returned.

      The returned value is in relative to aFromIndex/bFromIndex! As such, it will never be larger than either value.

      Parameters:
      a - The array a
      aFromIndex - The first index in array a of the section for that array
      aToIndex - The last index in array a of the section for that array
      b - The array b
      bFromIndex - The first index in array b of the section for that array
      bToIndex - The last index in array b of the section for that array
      Returns:
      The index of the first mismatch, relative from aFromIndex/bFromIndex.