/** * @param k another key * @return a new Key which is the result of this key XOR the given key */ public Key xor(Key k) { if (k.getByteLength() != getByteLength()) throw new IllegalArgumentException("incompatable key for xor"); byte[] b = new byte[getByteLength()]; for (int i = 0; i < b.length; ++i) { b[i] = (byte) (getBytes()[i] ^ k.getBytes()[i]); } return new Key(b); }
private int getKBucketIndex(Key key) { return key.xor(localNode.getKey()).getFirstSetBitIndex(); }
@Override public int compareTo(Key arg0) { return toString().compareTo(arg0.toString()); }