/** * Returns Hamming distance between the two bytes. */ public static int d(byte x, byte y) { return d((int)x, (int)y); }
/** * Returns Hamming distance between the two shorts. */ public static int d(short x, short y) { return d((int)x, (int)y); }
public void range(AbstractSentence q, double radius, List<Neighbor<AbstractSentence, E>> neighbors) { if (radius <= 0.0) { throw new IllegalArgumentException("Invalid radius: " + radius); } long fpq = simhash64(q.tokens); Set<Integer> candidates = obtainCandidates(q.tokens); for (int index : candidates) { double distance = HammingDistance.d(fpq, signs.get(index)); if (distance <= radius) { if (keys.get(index).line != q.line || !identicalExcluded) { neighbors.add(new Neighbor<>(keys.get(index), data.get(index), index, distance)); } } } }
double distance = HammingDistance.d(fpq, sign); if (distance < heap.peek().distance) { heap.add(new Neighbor<>(keys.get(index), data.get(index), index, distance));