Methods Summary |
---|
public void | adjustValuesBelow(int startRow, int column, int delta)Increments all values in the specified column whose row >= the
specified row by the specified delta.
if (((startRow | column) < 0) || (startRow > size()) ||
(column >= width())) {
throw new IndexOutOfBoundsException(startRow + ", " + column);
}
if (startRow >= mRowGapStart) {
startRow += mRowGapLength;
}
moveValueGapTo(column, startRow);
mValueGap[column + mColumns] += delta;
|
public void | deleteAt(int row, int count)Deletes the specified number of rows starting with the specified
row.
if (((row | count) < 0) || (row + count > size())) {
throw new IndexOutOfBoundsException(row + ", " + count);
}
moveRowGapTo(row + count);
mRowGapStart -= count;
mRowGapLength += count;
// TODO: Reclaim memory when the new height is much smaller
// than the allocated size.
|
public int | getValue(int row, int column)Returns the value at the specified row and column.
final int columns = mColumns;
if (((row | column) < 0) || (row >= size()) || (column >= columns)) {
throw new IndexOutOfBoundsException(row + ", " + column);
}
if (row >= mRowGapStart) {
row += mRowGapLength;
}
int value = mValues[row * columns + column];
int[] valuegap = mValueGap;
if (row >= valuegap[column]) {
value += valuegap[column + columns];
}
return value;
|
private final void | growBuffer()Grows the value and gap arrays to be large enough to store at least
one more than the current number of rows.
final int columns = mColumns;
int newsize = size() + 1;
newsize = ArrayUtils.idealIntArraySize(newsize * columns) / columns;
int[] newvalues = new int[newsize * columns];
final int[] valuegap = mValueGap;
final int rowgapstart = mRowGapStart;
int after = mRows - (rowgapstart + mRowGapLength);
if (mValues != null) {
System.arraycopy(mValues, 0, newvalues, 0, columns * rowgapstart);
System.arraycopy(mValues, (mRows - after) * columns,
newvalues, (newsize - after) * columns,
after * columns);
}
for (int i = 0; i < columns; i++) {
if (valuegap[i] >= rowgapstart) {
valuegap[i] += newsize - mRows;
if (valuegap[i] < rowgapstart) {
valuegap[i] = rowgapstart;
}
}
}
mRowGapLength += newsize - mRows;
mRows = newsize;
mValues = newvalues;
|
public void | insertAt(int row, int[] values)Inserts a new row of values at the specified row offset.
if ((row < 0) || (row > size())) {
throw new IndexOutOfBoundsException("row " + row);
}
if ((values != null) && (values.length < width())) {
throw new IndexOutOfBoundsException("value count " + values.length);
}
moveRowGapTo(row);
if (mRowGapLength == 0) {
growBuffer();
}
mRowGapStart++;
mRowGapLength--;
if (values == null) {
for (int i = mColumns - 1; i >= 0; i--) {
setValueInternal(row, i, 0);
}
} else {
for (int i = mColumns - 1; i >= 0; i--) {
setValueInternal(row, i, values[i]);
}
}
|
private final void | moveRowGapTo(int where)Moves the gap in the row indices to begin at the specified row.
if (where == mRowGapStart) {
return;
} else if (where > mRowGapStart) {
int moving = where + mRowGapLength - (mRowGapStart + mRowGapLength);
final int columns = mColumns;
final int[] valuegap = mValueGap;
final int[] values = mValues;
final int gapend = mRowGapStart + mRowGapLength;
for (int i = gapend; i < gapend + moving; i++) {
int destrow = i - gapend + mRowGapStart;
for (int j = 0; j < columns; j++) {
int val = values[i * columns+ j];
if (i >= valuegap[j]) {
val += valuegap[j + columns];
}
if (destrow >= valuegap[j]) {
val -= valuegap[j + columns];
}
values[destrow * columns + j] = val;
}
}
} else /* where < mRowGapStart */ {
int moving = mRowGapStart - where;
final int columns = mColumns;
final int[] valuegap = mValueGap;
final int[] values = mValues;
final int gapend = mRowGapStart + mRowGapLength;
for (int i = where + moving - 1; i >= where; i--) {
int destrow = i - where + gapend - moving;
for (int j = 0; j < columns; j++) {
int val = values[i * columns+ j];
if (i >= valuegap[j]) {
val += valuegap[j + columns];
}
if (destrow >= valuegap[j]) {
val -= valuegap[j + columns];
}
values[destrow * columns + j] = val;
}
}
}
mRowGapStart = where;
|
private final void | moveValueGapTo(int column, int where)Moves the gap in the values of the specified column to begin at
the specified row.
final int[] valuegap = mValueGap;
final int[] values = mValues;
final int columns = mColumns;
if (where == valuegap[column]) {
return;
} else if (where > valuegap[column]) {
for (int i = valuegap[column]; i < where; i++) {
values[i * columns + column] += valuegap[column + columns];
}
} else /* where < valuegap[column] */ {
for (int i = where; i < valuegap[column]; i++) {
values[i * columns + column] -= valuegap[column + columns];
}
}
valuegap[column] = where;
|
public void | setValue(int row, int column, int value)Sets the value at the specified row and column.
if (((row | column) < 0) || (row >= size()) || (column >= mColumns)) {
throw new IndexOutOfBoundsException(row + ", " + column);
}
if (row >= mRowGapStart) {
row += mRowGapLength;
}
int[] valuegap = mValueGap;
if (row >= valuegap[column]) {
value -= valuegap[column + mColumns];
}
mValues[row * mColumns + column] = value;
|
private void | setValueInternal(int row, int column, int value)Sets the value at the specified row and column.
Private internal version: does not check args.
if (row >= mRowGapStart) {
row += mRowGapLength;
}
int[] valuegap = mValueGap;
if (row >= valuegap[column]) {
value -= valuegap[column + mColumns];
}
mValues[row * mColumns + column] = value;
|
public int | size()Returns the number of rows in the PackedIntVector. This number
will change as rows are inserted and deleted.
return mRows - mRowGapLength;
|
public int | width()Returns the width of the PackedIntVector. This number is set
at construction and will not change.
return mColumns;
|