|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectiitb.con.util.IntArrayGrid
public class IntArrayGrid
IntArrayGrid is a unbound grid structure for integer values. The number of columns in the grid is fixed at creation time, while the rows are unbound. ArrayGrid is limited with the size of 4KB (by default), since it is useful to store in the disk.
Field Summary | |
---|---|
static int |
BLOCK_SIZE
Size of the BLOCK |
int |
id
Id for the array grid |
int |
length
Number of entries present in the grid |
Constructor Summary | |
---|---|
IntArrayGrid(int id,
int cols)
Initializes with id and number of columns |
|
IntArrayGrid(int id,
int cols,
java.nio.ByteBuffer buf)
Initializes with id and number of columns and the byte buffer is used to initial the values in the grid; will be useful if user is reading the data from the disk and constructing the array grid |
Method Summary | |
---|---|
int |
add(int... values)
Adds the values for a row to the grid |
void |
dump()
Prints the contents of array grid |
int[] |
getCol(int index)
Returns the column for the specified index |
int[] |
getRowByBinarySearch(int key)
Returns the row as integer array based on the given key match with first column. Returns first match in case of duplicate keys. |
int[][] |
getRows(int key,
int col)
Returns the rows as 2d integer array based on the given key match with the specified column. |
boolean |
setRow(int key,
int matchCol,
int... values)
Sets the row value based on the matching value in the grid |
void |
sort()
Sorts the grid based on the first column value |
java.nio.ByteBuffer |
toBuffer()
Returns the array grid contents as bytes |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BLOCK_SIZE
public int id
public int length
Constructor Detail |
---|
public IntArrayGrid(int id, int cols)
id
- id for the array grid; will be useful if a program uses multiple gridscols
- number of columnspublic IntArrayGrid(int id, int cols, java.nio.ByteBuffer buf)
id
- id for the array grid; will be useful if a program uses multiple gridscols
- number of columnsbuf
- array grid's bytebufferMethod Detail |
---|
public int add(int... values)
values
- variable number of values based on the column size
public void dump()
public int[] getCol(int index)
index
- column index
public int[] getRowByBinarySearch(int key)
key
- key value to be searched
public int[][] getRows(int key, int col)
key
- key value to be searchedcol
- the column to be searched
public boolean setRow(int key, int matchCol, int... values)
key
- key to be matchedmatchCol
- column used for matchingvalues
- values to be set
public void sort()
public java.nio.ByteBuffer toBuffer()
ByteBuffer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |