Java Memory memoryEqual(byte[] left, int leftOffset, byte[] right, int rightOffset, int length)

Here you can find the source of memoryEqual(byte[] left, int leftOffset, byte[] right, int rightOffset, int length)

Description

Description: Checks Whether the Two Parts of Arrays are Equal to Each Other

License

Open Source License

Parameter

Parameter Description
left Left Array
leftOffset Starting Point of the Left Array
right Right Array
rightOffset Starting Point of the Right Array
length Length to be Compared from the Starting Point

Return

true Equal false Different

Declaration

public static boolean memoryEqual(byte[] left, int leftOffset, byte[] right, int rightOffset, int length) 

Method Source Code

//package com.java2s;

public class Main {
    /****************************************************************************************************
     * Description:   Checks Whether the Two Parts of Arrays are Equal to Each Other
     *//from   w  w w  .  j  a  va  2  s  .c  o m
     * @param        left            Left Array
     * @param        leftOffset        Starting Point of the Left Array
     * @param        right            Right Array
     * @param        rightOffset        Starting Point of the Right Array
     * @param        length            Length to be Compared from the Starting Point
     *
     * @return true            Equal
     *            false         Different
     ****************************************************************************************************/
    public static boolean memoryEqual(byte[] left, int leftOffset, byte[] right, int rightOffset, int length) {

        if ((leftOffset + length <= left.length) && (rightOffset + length <= right.length)) {

            for (int i = 0; i < length; i++) {

                if (left[leftOffset + i] != right[rightOffset + i]) {

                    return false;

                }

            }

            return true;

        } else {

            return false;

        }

    }
}

Related

  1. makeVmMemoryDivisibleBy4(long memory)
  2. measureMemoryBefore()
  3. memory()
  4. memory()
  5. memory()
  6. memoryInfo()
  7. memoryIsLow()
  8. memoryOccupied()
  9. memorySize(long bytesSize)