Compares this byte sequence to another.

@param obs byte sequence to compare
@return comparison result
@see #compareBytes(ByteSequence, ByteSequence)
518976
public int compareTo(ByteSequence obs) {
        if (isBackedByArray() && obs.isBackedByArray()) {
            return WritableComparator.compareBytes(getBackingArray(), offset(), length(), obs.getBackingArray(), obs.offset(), obs.length());
        }

        return compareBytes(this, obs);
    }
801777
@Override
    public int compareTo(Histogram o) {
        int cmp = 0;
        final Iterator<Bucket> iter = buckets_.iterator(), o_iter = o.buckets_.iterator();
        while (cmp == 0 && iter.hasNext() && o_iter.hasNext()) {
            final Bucket next = iter.next(), o_next = o_iter.next();
            cmp = Double.compare(next.getRange().getFloor(), o_next.getRange().getFloor());
            if (cmp == 0)
                cmp = Double.compare(next.getRange().getCeil(), o_next.getRange().getCeil());
            if (cmp == 0)
                cmp = Double.compare(next.getEvents(), o_next.getEvents());
        }

        if (cmp == 0)
            cmp = (iter.hasNext() ? 1 : (o_iter.hasNext() ? -1 : 0));
        return cmp;
    }
494988
def byte_compare(stream_a, stream_b):
    
    bufsize = 16 * 1024
    equal = True
    ofs = 0
    while True:
        b1 = stream_a.read(bufsize)
        b2 = stream_b.read(bufsize)
        if b1 != b2:
            equal = False
            if b1 and b2:
                # we have two different buffers: find first mismatch
                for a, b in zip(b1, b2):
                    if a != b:
                        break
                    ofs += 1
            break
        ofs += len(b1)
        if not b1:  # both buffers empty
            break
    return (equal, ofs)
232559
public static boolean increment(byte[] bytes) {
        final int startIndex = 0;
        int i;
        for (i = bytes.length - 1; i >= startIndex; i--) {
            bytes[i]++;
            if (bytes[i] != 0)
                break;
        }
        // we return false when all bytes are 0 again
        return (i >= startIndex || bytes[startIndex] != 0);
    }
35124
@Override
    public int compareTo(Timestamp other) {
	if (unixSec < other.unixSec) {
            return -1;
        } else if (unixSec == other.unixSec) {
            if (nanoSec < other.nanoSec) {
                return -1;
            } else if (nanoSec == other.nanoSec) {
                return 0;
            } else {
                return 1;
            }
        } else {
            return 1;
        }
    }
778340
private static boolean compareByteValues(byte[] network,byte[] subnet,byte[] ipAddress)
    {    	
    	for(int i=0;i<network.length;i++)
    		if((network[i] & subnet[i]) != (ipAddress[i] & subnet[i]))
    			return false;
    	
    	return true;
    }
428132
protected static int findSequence(byte[] sequence, byte[] buffer) {
        int pos = -1;
        for (int i = 0; i < buffer.length - sequence.length + 1; i++) {
            if (buffer[i] == sequence[0] && testRemaining(sequence, buffer, i)) {
                pos = i;
                break;
            }
        }
        return pos;
    }
547406
public int compareTo(Object compareTo) throws ClassCastException {
		if (!(compareTo instanceof UUID)) {
			throw new ClassCastException();
		}
		return (Bytes.compareTo(rawBytes, ((UUID) compareTo).getRawBytes()));
	}
232584
private byte[] getBytesFromStream(final InputStream dstream)
			throws IOException {
		final ByteArrayOutputStream baos = new ByteArrayOutputStream();
		final byte[] buffer = new byte[1024];
		int read;
		while ((read = dstream.read(buffer)) > 0) {
			baos.write(buffer, 0, read);
		}
		return baos.toByteArray();
	}
209877
@Override
    public int compareTo(ZonalTransition other) {

        long delta = (this.posix - other.posix);

        if (delta == 0) {
            delta = (this.previous - other.previous);
            if (delta == 0) {
                delta = (this.total - other.total);
                if (delta == 0) {
                    delta = (this.getDaylightSavingOffset() - other.getDaylightSavingOffset());
                    if (delta == 0) {
                        return 0;
                    }
                }
            }
        }

        return ((delta < 0) ? -1 : 1);

    }
666317
public static int copyAllBytes(InputStream in, OutputStream out) throws IOException {
        int byteCount = 0;
        byte[] buffer = new byte[BUFFER_SIZE];
        while (true) {
            int read = in.read(buffer);
            if (read == -1) {
                break;
            }
            out.write(buffer, 0, read);
            byteCount += read;
        }
        return byteCount;
    }
311072
public static boolean sequenceEqualConstantTime(byte[] self, byte[] other) {
        if (self == null) {
            throw new IllegalArgumentException("self");
        }

        if (other == null) {
            throw new IllegalArgumentException("other");
        }

        // Constant time comparison of two byte arrays
        long difference = (self.length & 0xffffffffL) ^ (other.length & 0xffffffffL);

        for (int i = 0; i < self.length && i < other.length; i++) {
            difference |= (self[i] ^ other[i]) & 0xffffffffL;
        }

        return difference == 0;
    }
91342
@Override
    public int compareTo(MP4Frame that) {
        int ret = 0;
        if (this.time > that.getTime()) {
            ret = 1;
        } else if (this.time < that.getTime()) {
            ret = -1;
        } else if (Double.doubleToLongBits(time) == Double.doubleToLongBits(that.getTime()) && this.offset > that.getOffset()) {
            ret = 1;
        } else if (Double.doubleToLongBits(time) == Double.doubleToLongBits(that.getTime()) && this.offset < that.getOffset()) {
            ret = -1;
        }
        return ret;
    }
844625
public static byte[] bytes(InputStream in) throws IOException {
        if(in == null)
            throw new IllegalArgumentException("input stream cannot be null");

        ByteArrayOutputStream bout = new ByteArrayOutputStream(1024);
        byte[] bytes = new byte[1024];

        for (int x = in.read(bytes); x != -1; x = in.read(bytes))
            bout.write(bytes, 0, x);

        return bout.toByteArray();
    }
341409
@Override
    public byte[] encodeAsBytes(long time, int sequence) {
        byte[] buffer = new byte[16];
        buffer[0] = (byte) (time >>> 56);
        buffer[1] = (byte) (time >>> 48);
        buffer[2] = (byte) (time >>> 40);
        buffer[3] = (byte) (time >>> 32);
        buffer[4] = (byte) (time >>> 24);
        buffer[5] = (byte) (time >>> 16);
        buffer[6] = (byte) (time >>> 8);
        buffer[7] = (byte) (time);

        long rest = shiftedMachineId | (0x0000FFFF & sequence);
        buffer[8] = (byte) (rest >>> 56);
        buffer[9] = (byte) (rest >>> 48);
        buffer[10] = (byte) (rest >>> 40);
        buffer[11] = (byte) (rest >>> 32);
        buffer[12] = (byte) (rest >>> 24);
        buffer[13] = (byte) (rest >>> 16);
        buffer[14] = (byte) (rest >>> 8);
        buffer[15] = (byte) (rest);

        return buffer;
    }
738910
public static <T> int compare(Stream<T> s1, Stream<T> s2, Comparator<T> comp)
    {
        Iterator<T> os1 = s1.iterator();
        Iterator<T> os2 = s2.iterator();
        Comparable<T> comparable = null;
        while (os1.hasNext() && os2.hasNext())
        {
            T n1 = os1.next();
            T n2 = os2.next();
            int c;
            if (comp == null)
            {
                comparable = (Comparable<T>) n1;
                c = comparable.compareTo(n2);
            }
            else
            {
                c = comp.compare(n1, n2);
            }
            if (c != 0)
            {
                return c;
            }
        }
        boolean hn1 = os1.hasNext();
        boolean hn2 = os2.hasNext();
        if (hn1 == hn2)
        {
            return 0;
        }
        if (hn1)
        {
            return 1;
        }
        else
        {
            return -1;
        }
    }
1282823
public int compareTo(Object o) {
    int thisValue = this.value;
    int thatValue = ((ByteWritable)o).value;
    return (thisValue < thatValue ? -1 : (thisValue == thatValue ? 0 : 1));
  }