/** * Appends to the <code>builder</code> the comparison of * two <code>byte</code>s. * * @param lhs left-hand value * @param rhs right-hand value * @return this - used to chain append calls */ public CompareToBuilder append(final byte lhs, final byte rhs) { if (comparison != 0) { return this; } comparison = Byte.compare(lhs, rhs); return this; }
@Override public int compareTo(SessionID id) { int result = this.encodedForm.length - id.encodedForm.length; for (int i = 0; (result == 0) && (i < this.encodedForm.length); ++i) { result = Byte.compare(this.encodedForm[i], id.encodedForm[i]); } return result; }
/** * Compares this object to the specified byte object to determine their * relative order. * * @param object * the byte object to compare this object to. * @return a negative value if the value of this byte is less than the value * of {@code object}; 0 if the value of this byte and the value of * {@code object} are equal; a positive value if the value of this * byte is greater than the value of {@code object}. * @see java.lang.Comparable * @since 1.2 */ public int compareTo(Byte object) { return compare(value, object.value); }
@Override public int compareTo(ValueArray<ByteValue> o) { ByteValueArray other = (ByteValueArray) o; int min = Math.min(position, other.position); for (int i = 0; i < min; i++) { int cmp = Byte.compare(data[i], other.data[i]); if (cmp != 0) { return cmp; } } return Integer.compare(position, other.position); }
@Override public int compareTo(ValueArray<StringValue> o) { StringValueArray other = (StringValueArray) o; // sorts first on number of data in the array, then comparison between // the first non-equal element in the arrays int cmp = Integer.compare(position, other.position); if (cmp != 0) { return cmp; } for (int i = 0; i < position; i++) { cmp = Byte.compare(data[i], other.data[i]); if (cmp != 0) { return cmp; } } return 0; }
@Override public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition) { // WARNING: the correctness of InCodeGenerator is dependent on the implementation of this // function being the equivalence of internal long representation. byte leftValue = leftBlock.getByte(leftPosition, 0); byte rightValue = rightBlock.getByte(rightPosition, 0); return Byte.compare(leftValue, rightValue); }
@Override public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition) { // WARNING: the correctness of InCodeGenerator is dependent on the implementation of this // function being the equivalence of internal long representation. byte leftValue = leftBlock.getByte(leftPosition, 0); byte rightValue = rightBlock.getByte(rightPosition, 0); return Byte.compare(leftValue, rightValue); }
/** * Checks whether a file is terminated with exactly one trailing newline. * * @param inputFile the file to check for a trailing newline * @return true if file is terminated with exactly one newline * @throws IOException if the file cannot be read */ public static boolean singleNewlineTerminated(File inputFile) throws IOException { RandomAccessFile randomAccessFile = new RandomAccessFile(inputFile, READ_ONLY_MODE); // Zero terminating newlines if (inputFile.length() < 1) { return true; } randomAccessFile.seek(inputFile.length() - 1); if (Byte.compare(randomAccessFile.readByte(), NEWLINE_DELIMITER) != 0) { return false; } // File contains a single newline character and nothing else if (inputFile.length() < 2) { return true; } // More than one terminating newline randomAccessFile.seek(inputFile.length() - 2); return (Byte.compare(randomAccessFile.readByte(), NEWLINE_DELIMITER) != 0); }
private int byteArrayCompare( byte[] a, byte[] b, int fromPos ) { assert a != null && b != null : "Null arrays not supported."; if ( a == b ) { return 0; } int length = Math.min( a.length, b.length ); for ( int i = fromPos; i < length; i++ ) { int compare = Byte.compare( a[i], b[i] ); if ( compare != 0 ) { return compare; } } return Integer.compare( a.length, b.length ); }
@Override default int compare(T first, T second) { return Byte.compare( applyAsByte(first), applyAsByte(second) ); }
@Override public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException { int firstCount = firstSource.readInt(); int secondCount = secondSource.readInt(); int minCount = Math.min(firstCount, secondCount); while (minCount-- > 0) { byte firstValue = firstSource.readByte(); byte secondValue = secondSource.readByte(); int cmp = Byte.compare(firstValue, secondValue); if (cmp != 0) { return ascendingComparison ? cmp : -cmp; } } int cmp = Integer.compare(firstCount, secondCount); return ascendingComparison ? cmp : -cmp; }
/** {@inheritDoc} */ @Override protected int compare(final BPlusIO<IndexItem> io, final long pageAddr, final int idx, final IndexItem row) throws IgniteCheckedException { final int off = ((IndexIO)io).getOffset(pageAddr, idx); int shift = 0; // Compare index names. final int len = PageUtils.getUnsignedByte(pageAddr, off + shift); shift += BYTE_LEN; for (int i = 0; i < len && i < row.idxName.length; i++) { final int cmp = Byte.compare(PageUtils.getByte(pageAddr, off + i + shift), row.idxName[i]); if (cmp != 0) return cmp; } return Integer.compare(len, row.idxName.length); }
public int compareTo(final DirectBuffer that) { final int thisCapacity = this.capacity; final int thatCapacity = that.capacity(); final byte[] thisByteArray = this.byteArray; final byte[] thatByteArray = that.byteArray(); final long thisOffset = this.addressOffset; final long thatOffset = that.addressOffset(); for (int i = 0, length = Math.min(thisCapacity, thatCapacity); i < length; i++) { final int cmp = Byte.compare( UNSAFE.getByte(thisByteArray, thisOffset + i), UNSAFE.getByte(thatByteArray, thatOffset + i)); if (0 != cmp) { return cmp; } } if (thisCapacity != thatCapacity) { return thisCapacity - thatCapacity; } return 0; }
@Override public int compareTo(TByteBuffer other) { if (this == other) { return 0; } int sz = Math.min(remaining(), other.remaining()); int a = position + start; int b = other.position + other.start; for (int i = 0; i < sz; ++i) { int r = Byte.compare(array[a++], other.array[b++]); if (r != 0) { return r; } } return Integer.compare(remaining(), other.remaining()); }
public int compareTo(final DirectBuffer that) { final int thisCapacity = this.capacity(); final int thatCapacity = that.capacity(); final byte[] thisByteArray = this.byteArray; final byte[] thatByteArray = that.byteArray(); final long thisOffset = this.addressOffset(); final long thatOffset = that.addressOffset(); for (int i = 0, length = Math.min(thisCapacity, thatCapacity); i < length; i++) { final int cmp = Byte.compare( UNSAFE.getByte(thisByteArray, thisOffset + i), UNSAFE.getByte(thatByteArray, thatOffset + i)); if (0 != cmp) { return cmp; } } if (thisCapacity != thatCapacity) { return thisCapacity - thatCapacity; } return 0; }
public int compareTo(final DirectBuffer that) { final int thisCapacity = this.capacity(); final int thatCapacity = that.capacity(); final byte[] thisByteArray = null; final byte[] thatByteArray = that.byteArray(); final long thisOffset = this.addressOffset(); final long thatOffset = that.addressOffset(); for (int i = 0, length = Math.min(thisCapacity, thatCapacity); i < length; i++) { final int cmp = Byte.compare( UNSAFE.getByte(thisByteArray, thisOffset + i), UNSAFE.getByte(thatByteArray, thatOffset + i)); if (0 != cmp) { return cmp; } } if (thisCapacity != thatCapacity) { return thisCapacity - thatCapacity; } return 0; }
@Override public int compare(T first, T second) { final boolean f = isNull(first); final boolean s = isNull(second); if (f && s) return 0; else if (f) return 1; else if (s) return -1; else return Byte.compare( original.applyAsByte(first), original.applyAsByte(second) ); }
@Override public int compare(ENTITY first, ENTITY second) { requireNonNulls(first, second); final byte a = field.getAsByte(first); final byte b = field.getAsByte(second); return applyReversed(Byte.compare(a, b)); }
@Override default int compare(T first, T second) { if (isNull(first)) { return isNull(second) ? 0 : 1; } else if (isNull(second)) { return -1; } else { return Byte.compare( applyAsByte(first), applyAsByte(second) ); } }
byte secondByte = second.arr[secondDataStart + i]; res = Byte.compare(firstByte, secondByte);