/** * Return true if the two EWAHCompressedBitmap have both at least one * true bit in the same position. Equivalently, you could call "and" and * check whether there is a set bit, but intersects will run faster if * you don't need the result of the "and" operation. * * The current bitmap is not modified. * * @param a the other bitmap (it will not be modified) * @return whether they intersect * @since 0.3.2 */ public boolean intersects(final EWAHCompressedBitmap a) { NonEmptyVirtualStorage nevs = new NonEmptyVirtualStorage(); try { this.andToContainer(a, nevs); } catch (NonEmptyVirtualStorage.NonEmptyException nee) { return true; } return false; }
/** * Return true if the two EWAHCompressedBitmap have both at least one * true bit in the same position. Equivalently, you could call "and" and * check whether there is a set bit, but intersects will run faster if * you don't need the result of the "and" operation. * * The current bitmap is not modified. * * @param a the other bitmap (it will not be modified) * @return whether they intersect * @since 0.3.2 */ public boolean intersects(final EWAHCompressedBitmap a) { NonEmptyVirtualStorage nevs = new NonEmptyVirtualStorage(); try { this.andToContainer(a, nevs); } catch (NonEmptyVirtualStorage.NonEmptyException nee) { return true; } return false; }
throw new IllegalArgumentException("Need at least one bitmap"); if (bitmaps.length == 2) { bitmaps[0].andToContainer(bitmaps[1], container); return; EWAHCompressedBitmap tmp = new EWAHCompressedBitmap(initialSize); bitmaps[0].andToContainer(bitmaps[1], answer); for (int k = 2; k < bitmaps.length - 1; ++k) { answer.andToContainer(bitmaps[k], tmp); EWAHCompressedBitmap tmp2 = answer; answer = tmp; tmp.clear(); answer.andToContainer(bitmaps[bitmaps.length - 1], container);
throw new IllegalArgumentException("Need at least one bitmap"); if (bitmaps.length == 2) { bitmaps[0].andToContainer(bitmaps[1], container); return; EWAHCompressedBitmap tmp = new EWAHCompressedBitmap(initialSize); bitmaps[0].andToContainer(bitmaps[1], answer); for (int k = 2; k < bitmaps.length - 1; ++k) { answer.andToContainer(bitmaps[k], tmp); EWAHCompressedBitmap tmp2 = answer; answer = tmp; tmp.clear(); answer.andToContainer(bitmaps[bitmaps.length - 1], container);
/** * Returns the cardinality of the result of a bitwise AND of the values * of the current bitmap with some other bitmap. Avoids * allocating an intermediate bitmap to hold the result of the OR. * * The current bitmap is not modified. * * @param a the other bitmap (it will not be modified) * @return the cardinality * @since 0.4.0 */ public int andCardinality(final EWAHCompressedBitmap a) { final BitCounter counter = new BitCounter(); andToContainer(a, counter); return counter.getCount(); }
/** * Returns the cardinality of the result of a bitwise AND of the values * of the current bitmap with some other bitmap. Avoids * allocating an intermediate bitmap to hold the result of the OR. * * The current bitmap is not modified. * * @param a the other bitmap (it will not be modified) * @return the cardinality * @since 0.4.0 */ public int andCardinality(final EWAHCompressedBitmap a) { final BitCounter counter = new BitCounter(); andToContainer(a, counter); return counter.getCount(); }
EWAHCompressedBitmap answer = new EWAHCompressedBitmap(initialSize); EWAHCompressedBitmap tmp = new EWAHCompressedBitmap(initialSize); bitmaps[0].andToContainer(bitmaps[1], answer); for (int k = 2; k < bitmaps.length; ++k) { answer.andToContainer(bitmaps[k], tmp); tmp.swap(answer); tmp.clear();
EWAHCompressedBitmap answer = new EWAHCompressedBitmap(initialSize); EWAHCompressedBitmap tmp = new EWAHCompressedBitmap(initialSize); bitmaps[0].andToContainer(bitmaps[1], answer); for (int k = 2; k < bitmaps.length; ++k) { answer.andToContainer(bitmaps[k], tmp); tmp.swap(answer); tmp.clear();
/** * Returns a new compressed bitmap containing the bitwise AND values of * the current bitmap with some other bitmap. * * The running time is proportional to the sum of the compressed sizes * (as reported by sizeInBytes()). * * If you are not planning on adding to the resulting bitmap, you may * call the trim() method to reduce memory usage. * * The current bitmap is not modified. * * @param a the other bitmap (it will not be modified) * @return the EWAH compressed bitmap * @since 0.4.3 */ @Override public EWAHCompressedBitmap and(final EWAHCompressedBitmap a) { int size = this.buffer.sizeInWords() > a.buffer.sizeInWords() ? this.buffer.sizeInWords() : a.buffer.sizeInWords(); final EWAHCompressedBitmap container = new EWAHCompressedBitmap(size); andToContainer(a, container); return container; }
/** * Returns a new compressed bitmap containing the bitwise AND values of * the current bitmap with some other bitmap. * * The running time is proportional to the sum of the compressed sizes * (as reported by sizeInBytes()). * * If you are not planning on adding to the resulting bitmap, you may * call the trim() method to reduce memory usage. * * The current bitmap is not modified. * * @param a the other bitmap (it will not be modified) * @return the EWAH compressed bitmap * @since 0.4.3 */ @Override public EWAHCompressedBitmap and(final EWAHCompressedBitmap a) { int size = this.buffer.sizeInWords() > a.buffer.sizeInWords() ? this.buffer.sizeInWords() : a.buffer.sizeInWords(); final EWAHCompressedBitmap container = new EWAHCompressedBitmap(size); andToContainer(a, container); return container; }