Guava UnsignedInteger - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava UnsignedInteger class.

This code example shows how to use the following methods:equals
      if (!(o instanceof HdKeyPath)) return false; 
 
      HdKeyPath hdKeyPath = (HdKeyPath) o;
 
      if (hardened != hdKeyPath.hardened) return false;
      if (!index.equals(hdKeyPath.index)) return false;
      if (!parent.equals(hdKeyPath.parent)) return false;
 
      return true; 
   } 
 
   @Override 
   public int hashCode() { 
      int result = parent.hashCode();
      result = 31 * result + index.hashCode();
      result = 31 * result + (hardened ? 1 : 0);
      return result;
   } 
} 
4
CodeRank
This code example shows how to use the following methods:longValue
    public static int sizeOf(long value) {
        if (isLessThanUnsigned(value, 253))
            return 1; 
        else if (isLessThanUnsigned(value, 65536))
            return 3;  // 1 marker + 2 data bytes 
        else if (isLessThanUnsigned(value, UnsignedInteger.MAX_VALUE.longValue()))
            return 5;  // 1 marker + 4 data bytes 
        else 
            return 9;  // 1 marker + 8 data bytes 
    } 
 
    public byte[] encode() { 
        if (isLessThanUnsigned(value, 253)) {
            return new byte[]{(byte) value};
        } else if (isLessThanUnsigned(value, 65536)) {
            return new byte[]{(byte) 253, (byte) (value), (byte) (value >> 8)};
        } else if (isLessThanUnsigned(value, UnsignedInteger.MAX_VALUE.longValue())) {
            byte[] bytes = new byte[5];
            bytes[0] = (byte) 254;
            Utils.uint32ToByteArrayLE(value, bytes, 1);
3
CodeRank
This code example shows how to use the following methods:longValue
    public static int sizeOf(long value) {
        if (isLessThanUnsigned(value, 253))
            return 1; 
        else if (isLessThanUnsigned(value, 65536))
            return 3;  // 1 marker + 2 data bytes 
        else if (isLessThanUnsigned(value, UnsignedInteger.MAX_VALUE.longValue()))
            return 5;  // 1 marker + 4 data bytes 
        else 
            return 9;  // 1 marker + 8 data bytes 
    } 
 
    public byte[] encode() { 
        if (isLessThanUnsigned(value, 253)) {
            return new byte[]{(byte) value};
        } else if (isLessThanUnsigned(value, 65536)) {
            return new byte[]{(byte) 253, (byte) (value), (byte) (value >> 8)};
        } else if (isLessThanUnsigned(value, UnsignedInteger.MAX_VALUE.longValue())) {
            byte[] bytes = new byte[5];
            bytes[0] = (byte) 254;
            Utils.uint32ToByteArrayLE(value, bytes, 1);
3
CodeRank
See Code Examples for Guava UnsignedInteger Methods: