@Override public Bitmap flip(int rangeStart, int rangeEnd) { // synthesized with 2-upper-bounded NOTs int savedSize = bitmap.sizeInBits(); EWAHCompressedBitmap32 temp = null; try { temp = (EWAHCompressedBitmap32) bitmap.clone(); } catch (CloneNotSupportedException e) { } ; temp.setSizeInBits(rangeEnd, false); temp.not(); if (rangeStart != 0) { temp.setSizeInBits(rangeStart - 1, false); temp.not(); } temp.setSizeInBits(savedSize, false); return new Ewah32BitmapWrapper(temp); }
int length = iterator.nextLength(); index += length; container.setSizeInBits(index, false); iterator.move(length); } else { int length = Math.min(iterator.nextLength(), aIterator.nextLength()); index += length; container.setSizeInBits(index, aIterator.nextBit()); iterator.move(length); aIterator.move(length); container.setSizeInBits(sizeInBits, false);
int length = iterator.nextLength(); index += length; container.setSizeInBits(index, false); iterator.move(length); } else { int length = Math.min(iterator.nextLength(), aIterator.nextLength()); index += length; container.setSizeInBits(index, aIterator.nextBit()); iterator.move(length); aIterator.move(length); container.setSizeInBits(sizeInBits, false);
/** * Set the size in bits. This does not change the compressed bitmap. */ @Override public void setSizeInBitsWithinLastWord(final int size) { // TODO: This method could be replaced with setSizeInBits if ((size + WORD_IN_BITS - 1) / WORD_IN_BITS > (this.sizeInBits + WORD_IN_BITS - 1) / WORD_IN_BITS) { setSizeInBits(size,false); return; } if ((size + WORD_IN_BITS - 1) / WORD_IN_BITS != (this.sizeInBits + WORD_IN_BITS - 1) / WORD_IN_BITS) throw new RuntimeException( "You can only reduce the size of the bitmap within the scope of the last word. To extend the bitmap, please call setSizeInbits(int,boolean): " + size + " " + this.sizeInBits ); this.sizeInBits = size; final int usedBitsInLast = this.sizeInBits % WORD_IN_BITS; if (usedBitsInLast == 0) return; if (this.rlw.getNumberOfLiteralWords() == 0) { if (this.rlw.getRunningLength() > 0) { this.rlw.setRunningLength(this.rlw .getRunningLength() - 1); final int word = this.rlw.getRunningBit() ? (~0) >>> (WORD_IN_BITS - usedBitsInLast) : 0; this.insertLiteralWord(word); } return; } this.buffer.andLastWord((~0) >>> (WORD_IN_BITS - usedBitsInLast)); }
/** * Set the size in bits. This does not change the compressed bitmap. */ @Override public void setSizeInBitsWithinLastWord(final int size) { // TODO: This method could be replaced with setSizeInBits if ((size + WORD_IN_BITS - 1) / WORD_IN_BITS > (this.sizeInBits + WORD_IN_BITS - 1) / WORD_IN_BITS) { setSizeInBits(size,false); return; } if ((size + WORD_IN_BITS - 1) / WORD_IN_BITS != (this.sizeInBits + WORD_IN_BITS - 1) / WORD_IN_BITS) throw new RuntimeException( "You can only reduce the size of the bitmap within the scope of the last word. To extend the bitmap, please call setSizeInbits(int,boolean): " + size + " " + this.sizeInBits ); this.sizeInBits = size; final int usedBitsInLast = this.sizeInBits % WORD_IN_BITS; if (usedBitsInLast == 0) return; if (this.rlw.getNumberOfLiteralWords() == 0) { if (this.rlw.getRunningLength() > 0) { this.rlw.setRunningLength(this.rlw .getRunningLength() - 1); final int word = this.rlw.getRunningBit() ? (~0) >>> (WORD_IN_BITS - usedBitsInLast) : 0; this.insertLiteralWord(word); } return; } this.buffer.andLastWord((~0) >>> (WORD_IN_BITS - usedBitsInLast)); }