Package icyllis.modernui.text

# Class PackedIntVector

java.lang.Object
icyllis.modernui.text.PackedIntVector

public class PackedIntVector extends Object
PackedIntVector stores a two-dimensional array of integers, optimized for inserting and deleting rows and for offsetting the values in segments of a given column.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PackedIntVector(int columns)`
  Creates a new PackedIntVector with the specified width and a height of 0.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `adjustValuesBelow(int startRow, int column, int delta)`
  Increments all values in the specified column whose row >= the specified row by the specified delta.
  `void`
  `deleteAt(int row, int count)`
  Deletes the specified number of rows starting with the specified row.
  `int`
  `getValue(int row, int column)`
  Returns the value at the specified row and column.
  `void`
  `insertAt(int row, int[] values)`
  Inserts a new row of values at the specified row offset.
  `void`
  `setValue(int row, int column, int value)`
  Sets the value at the specified row and column.
  `int`
  `size()`
  Returns the number of rows in the PackedIntVector.
  `int`
  `width()`
  Returns the width of the PackedIntVector.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### PackedIntVector

    public PackedIntVector(int columns)
    Creates a new PackedIntVector with the specified width and a height of 0.
    Parameters:
      `columns` - the width of the PackedIntVector.

- ## Method Details

  - ### getValue

    public int getValue(int row, int column)
    Returns the value at the specified row and column.
    Parameters:
      `row` - the index of the row to return.
      `column` - the index of the column to return.
    Returns:
      the value stored at the specified position.
    Throws:
      `IndexOutOfBoundsException` - if the row is out of range (row < 0 || row >= size()) or the column is out of range (column < 0 || column >= width()).

  - ### setValue

    public void setValue(int row, int column, int value)
    Sets the value at the specified row and column.
    Parameters:
      `row` - the index of the row to set.
      `column` - the index of the column to set.
    Throws:
      `IndexOutOfBoundsException` - if the row is out of range (row < 0 || row >= size()) or the column is out of range (column < 0 || column >= width()).

  - ### adjustValuesBelow

    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.
    Parameters:
      `startRow` - the row at which to begin incrementing. This may be == size(), which case there is no effect.
      `column` - the index of the column to set.
    Throws:
      `IndexOutOfBoundsException` - if the row is out of range (startRow < 0 || startRow > size()) or the column is out of range (column < 0 || column >= width()).

  - ### insertAt

    public void insertAt(int row, int[] values)
    Inserts a new row of values at the specified row offset.
    Parameters:
      `row` - the row above which to insert the new row. This may be == size(), which case the new row is added at the end.
      `values` - the new values to be added. If this is null, a row of zeroes is added.
    Throws:
      `IndexOutOfBoundsException` - if the row is out of range (row < 0 || row > size()) or if the length of the values array is too small (values.length invalid input: '<' width()).

  - ### deleteAt

    public void deleteAt(int row, int count)
    Deletes the specified number of rows starting with the specified row.
    Parameters:
      `row` - the index of the first row to be deleted.
      `count` - the number of rows to delete.
    Throws:
      `IndexOutOfBoundsException` - if any of the rows to be deleted are out of range (row < 0 || count < 0 || row + count > size()).

  - ### size

    public int size()
    Returns the number of rows in the PackedIntVector. This number will change as rows are inserted and deleted.
    Returns:
      the number of rows.

  - ### width

    public int width()
    Returns the width of the PackedIntVector. This number is set at construction and will not change.
    Returns:
      the number of columns.