/** * {@inheritDoc} */ public Key subtract(Key otherKey) { /* * 0 - 0 => 0 * 0 - 1 => 0 * 1 - 0 => 1 * 1 - 1 => 0 * a and !b */ BitSetKey other = (BitSetKey) otherKey; int len = Math.max(bits.length, other.bits.length); long[] newBits = new long[len]; int numBits = 0; for (int i = 0; i < len; i++) { long w1 = i < bits.length ? bits[i] : 0; long w2 = i < other.bits.length ? other.bits[i] : 0; newBits[i] = w1 & ~w2; numBits += bitCount(newBits[i]); } return new BitSetKey(newBits, numBits); }
/** * {@inheritDoc} */ public Key subtract(Key otherKey) { /* * 0 - 0 => 0 * 0 - 1 => 0 * 1 - 0 => 1 * 1 - 1 => 0 * a and !b */ BitSetKey other = (BitSetKey) otherKey; int len = Math.max(bits.length, other.bits.length); long[] newBits = new long[len]; int numBits = 0; for (int i = 0; i < len; i++) { long w1 = i < bits.length ? bits[i] : 0; long w2 = i < other.bits.length ? other.bits[i] : 0; newBits[i] = w1 & ~w2; numBits += bitCount(newBits[i]); } return new BitSetKey(newBits, numBits); }
/** * {@inheritDoc} */ public Key getKey(Name[] ntNames) { return new BitSetKey(ntNames, nameIndex.size() + ntNames.length); }
/** * {@inheritDoc} */ public Key getKey(Name[] ntNames) { return new BitSetKey(ntNames, nameIndex.size() + ntNames.length); }