|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hsqldb.lib.DoubleIntTable
Minimal class for maintaining and searching an int to int sorted lookup table. This is suitable for very large lookups where memory footprint concerns are paramount.
This class does not distinguish between the key and the value until the find() method is invoked. At this point, the table is sorted on the specified column. Invoking find() on the other column will result in a new sort. If the values in the key list are not unique, any index with the target key value will be returned. The adjacent value pairs may hold the same key.
The arrays grow to twice the size when the current size is reached. Methods in this class throw the normal Java exceptions if invalid arguments are used (e.g. out of bounds values).
The arrays are sorted on the key values prior to each lookup unless no keys are modified or added since the last lookup. The find() method uses a binary search each time it is invoked.
This class is slower than IntKeyIntValueHashMap and should be used in preference only when memory use is more important than speed.
The search and sort methods are from UnifiedTable, originally written by Tony Lai.
Constructor Summary | |
DoubleIntTable(int size)
|
Method Summary | |
void |
add(int value1,
int value2)
Adds a key, value pair into the table. |
int |
find(int column,
int value)
|
int |
get(int index,
int column)
|
void |
putPair(int index,
int value1,
int value2)
Puts a key, value pair into the table at a given index. |
void |
putSingle(int index,
int column,
int value)
Puts a single value into the table. |
int |
size()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DoubleIntTable(int size)
Method Detail |
public int size()
public int get(int index, int column)
public void putSingle(int index, int column, int value)
index
- index into the arraycolumn
- the column to insert (0 or 1)value
- the value to insertpublic void putPair(int index, int value1, int value2)
index
- index into the arrayvalue1
- value for column 0value2
- value for column 1public void add(int value1, int value2)
value1
- value for column 0value2
- value for column 1public int find(int column, int value)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |