org.hsqldb.lib
Class DoubleIntTable

java.lang.Object
  extended byorg.hsqldb.lib.DoubleIntTable

public class DoubleIntTable
extends Object

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.

Since:
1.7.2
Version:
1.7.2
Author:
fredt@users, tony_lai@users

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

DoubleIntTable

public DoubleIntTable(int size)
Method Detail

size

public int size()

get

public int get(int index,
               int column)

putSingle

public void putSingle(int index,
                      int column,
                      int value)
Puts a single value into the table.

Parameters:
index - index into the array
column - the column to insert (0 or 1)
value - the value to insert

putPair

public void putPair(int index,
                    int value1,
                    int value2)
Puts a key, value pair into the table at a given index.

Parameters:
index - index into the array
value1 - value for column 0
value2 - value for column 1

add

public void add(int value1,
                int value2)
Adds a key, value pair into the table.

Parameters:
value1 - value for column 0
value2 - value for column 1

find

public int find(int column,
                int value)


Copyright © 2001 - 2004 HSQL Development Group. All Rights Reserved.