예제 #1
0
 /**
  * @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);
 }
예제 #2
0
 private int getKBucketIndex(Key key) {
   return key.xor(localNode.getKey()).getFirstSetBitIndex();
 }
예제 #3
0
 @Override
 public int compareTo(Key arg0) {
   return toString().compareTo(arg0.toString());
 }