Java Byte Array Compare memcmp(byte[] a, byte[] b)

Here you can find the source of memcmp(byte[] a, byte[] b)

Description

memcmp

License

Open Source License

Declaration

private static int memcmp(byte[] a, byte[] b) 

Method Source Code

//package com.java2s;
/*//from   w  ww .j  a va2 s.co m
 * Copyright (c) 2013 ICM Uniwersytet Warszawski All rights reserved.
 * See LICENCE.txt file for licensing information.
 */

public class Main {
    private static int memcmp(byte[] a, byte[] b) {
        int min = a.length > b.length ? b.length : a.length;
        for (int i = 0; i < min; i++)
            if (a[i] < b[i])
                return -1;
            else if (a[i] > b[i])
                return 1;
        return a.length - b.length;
    }
}

Related

  1. bytesCmp(byte[] oi, byte[] oj)
  2. bytesCompare(byte[] a, byte[] b)
  3. bytesCompare(byte[] a, byte[] b)
  4. bytesCompare(byte[] bytes1, byte[] bytes2)
  5. memcmp(byte a[], int a_off, byte b[], int b_off, int len)
  6. memcmp(byte[] a, int a_offset, byte[] b, int b_offset, int length)
  7. memcmp(byte[] a, int aoff, int alen, byte[] b, int boff, int blen)
  8. memcmp(byte[] bytes, byte[] bytes2, int nbElem)
  9. memcmp(byte[] s1, int s1Size, int s1offset, byte[] s2, int s2Size, int s2offset)