Java Byte Array Compare memcmp(byte a[], int a_off, byte b[], int b_off, int len)

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

Description

memcmp

License

Open Source License

Declaration

public static int memcmp(byte a[], int a_off, byte b[], int b_off,
            int len) 

Method Source Code

//package com.java2s;
/* Util.java -- utility functions

 This file is part of the LZO real-time data compression library.

 Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
 Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer

 The LZO library is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as
 published by the Free Software Foundation; either version 2 of
 the License, or (at your option) any later version.

 The LZO library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with the LZO library; see the file COPYING.
 If not, write to the Free Software Foundation, Inc.,
 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

 Markus F.X.J. Oberhumer/*from  w  ww .  j a v  a  2  s  .  co  m*/
 <markus.oberhumer@jk.uni-linz.ac.at>
 http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html
 */

public class Main {
    public static int memcmp(byte a[], int a_off, byte b[], int b_off,
            int len) {
        for (; len-- > 0; a_off++, b_off++)
            if (a[a_off] != b[b_off])
                return (a[a_off] & 0xff) - (b[b_off] & 0xff);
        return 0;
    }

    public static int memcmp(byte a[], byte b[], int len) {
        return memcmp(a, 0, b, 0, len);
    }
}

Related

  1. ArrayByteCompare(byte[] a, byte[] b)
  2. bytesCmp(byte[] oi, byte[] oj)
  3. bytesCompare(byte[] a, byte[] b)
  4. bytesCompare(byte[] a, byte[] b)
  5. bytesCompare(byte[] bytes1, byte[] bytes2)
  6. memcmp(byte[] a, byte[] b)
  7. memcmp(byte[] a, int a_offset, byte[] b, int b_offset, int length)
  8. memcmp(byte[] a, int aoff, int alen, byte[] b, int boff, int blen)
  9. memcmp(byte[] bytes, byte[] bytes2, int nbElem)