/** * Creates an empty bitmap (no bit set to true). */ public EWAHCompressedBitmap32() { this(new IntArray()); }
@Override public void andLastWord(int mask) { andWord(this.actualSizeInWords - 1, mask); }
@Override public int getLastWord() { return getWord(this.actualSizeInWords - 1); }
@Override public void push_back(int word) { resizeBuffer(1); this.buffer[this.actualSizeInWords++] = word; }
@Override public void setLastWord(int word) { setWord(this.actualSizeInWords - 1, word); }
@Override public void collapse(int position, int length) { System.arraycopy(this.buffer, position + length, this.buffer, position, this.actualSizeInWords - position - length); for(int i = 0; i < length; ++i) { removeLastWord(); } }
/** * Resizes the buffer if the number of words to add exceeds the buffer capacity. * @param number the number of words to add */ private void resizeBuffer(int number) { int size = newSizeInWords(number); if (size >= this.buffer.length) { int oldBuffer[] = this.buffer; this.buffer = new int[size]; System.arraycopy(oldBuffer, 0, this.buffer, 0, oldBuffer.length); } }
@Override public void orLastWord(int mask) { orWord(this.actualSizeInWords - 1, mask); }
@Override public void swap(final Buffer32 other) { if(other instanceof IntArray) { int[] tmp = this.buffer; this.buffer = ((IntArray) other).buffer; ((IntArray) other).buffer = tmp; int tmp2 = this.actualSizeInWords; this.actualSizeInWords = ((IntArray) other).actualSizeInWords; ((IntArray) other).actualSizeInWords = tmp2; } else { int[] tmp = new int[other.sizeInWords()]; for(int i = 0; i < other.sizeInWords(); ++i) { tmp[i] = other.getWord(i); } int tmp2 = other.sizeInWords(); other.clear(); other.removeLastWord(); other.push_back(this, 0, this.sizeInWords()); this.buffer = tmp; this.actualSizeInWords = tmp2; } }
@Override public void push_back(int word) { resizeBuffer(1); this.buffer[this.actualSizeInWords++] = word; }
@Override public void removeLastWord() { setWord(--this.actualSizeInWords, 0); }
@Override public void collapse(int position, int length) { System.arraycopy(this.buffer, position + length, this.buffer, position, this.actualSizeInWords - position - length); for(int i = 0; i < length; ++i) { removeLastWord(); } }
/** * Resizes the buffer if the number of words to add exceeds the buffer capacity. * @param number the number of words to add */ private void resizeBuffer(int number) { int size = newSizeInWords(number); if (size >= this.buffer.length) { int oldBuffer[] = this.buffer; this.buffer = new int[size]; System.arraycopy(oldBuffer, 0, this.buffer, 0, oldBuffer.length); } }
@Override public void orLastWord(int mask) { orWord(this.actualSizeInWords - 1, mask); }
@Override public void swap(final Buffer32 other) { if(other instanceof IntArray) { int[] tmp = this.buffer; this.buffer = ((IntArray) other).buffer; ((IntArray) other).buffer = tmp; int tmp2 = this.actualSizeInWords; this.actualSizeInWords = ((IntArray) other).actualSizeInWords; ((IntArray) other).actualSizeInWords = tmp2; } else { int[] tmp = new int[other.sizeInWords()]; for(int i = 0; i < other.sizeInWords(); ++i) { tmp[i] = other.getWord(i); } int tmp2 = other.sizeInWords(); other.clear(); other.removeLastWord(); other.push_back(this, 0, this.sizeInWords()); this.buffer = tmp; this.actualSizeInWords = tmp2; } }
@Override public void ensureCapacity(int capacity) { resizeBuffer(capacity - this.actualSizeInWords); }
/** * Creates an empty bitmap (no bit set to true). */ public EWAHCompressedBitmap32() { this(new IntArray()); }
@Override public void removeLastWord() { setWord(--this.actualSizeInWords, 0); }
@Override public int getLastWord() { return getWord(this.actualSizeInWords - 1); }
@Override public void andLastWord(int mask) { andWord(this.actualSizeInWords - 1, mask); }