Top Description Fields Constructors Methods
org.hsqldb.lib

public Class IntIndex

extends Object
Class Inheritance
Imports
java.util.Arrays

Maintains an ordered integer index. Equal keys are allowed. findXXX() methods return the array index into the list containing a matching key, or -1 if not found.
Author
Fred Toussi (fredt@users dot sourceforge.net)
Since
2.3.3
Version
2.5.0

Field Summary

Modifier and TypeField and Description
private int
private int
private final boolean
private int[]
private boolean
private int

Constructor Summary

AccessConstructor and Description
public
IntIndex(int capacity, boolean fixedSize)

Method Summary

Modifier and TypeMethod and Description
public synchronized int

Returns:

index of added key or -1 if full
add
(int
the key
key
)

Adds a key, maintaining sort order on current search target column.

public synchronized boolean

Returns:

true or false depending on success
addSorted
(int
the key
key
)

Adds a key into the table with the guarantee that the key is equal or larger than the largest existing key.

public synchronized boolean

Returns:

true or false depending on success
addUnique
(int
the key
key
)

Adds a key, ensuring no duplicate key already exists in the current search target column.

public synchronized boolean

Returns:

true or false depending on success
addUnsorted
(int
the key
key
)

Adds a key into the table.

private int

Returns:

the index
binaryEmptySlotSearch
()

Returns the index of the lowest element > the given search target or count or -1 if target is found

private int

Returns:

index or -1 if not found
binaryFirstSearch
()

Returns the index of the lowest element == the given search target, or -1

private int

Returns:

the index
binarySlotSearch
()

Returns the index of the lowest element >= the given search target, or count

public synchronized int
public void
protected int

Returns:

-1, 0 or +1
compare
(int
the index
i
)

Check if targeted column value in the row indexed i is less than the search target object.

protected void
private synchronized void
fastQuickSort()

fast quicksort using a stack on the heap to reduce stack use

private synchronized void
fastQuickSortRecursive()

fast quicksort with recursive quicksort implementation

public synchronized int
findFirstConsecutiveKeys(int
the number of consecutive keys required
number
)

Returns: the index or -1 if not found

public synchronized int
findFirstEqualKeyIndex(int
the value
value
)

Returns: the index

public synchronized int
findFirstGreaterEqualKeyIndex(int
the value
value
)

Returns: the index

public synchronized int

Returns:

the index
findFirstGreaterEqualSlotIndex
(int
the value
value
)

This method is similar to findFirstGreaterEqualKeyIndex(int) but returns the index of the empty row past the end of the array if the search value is larger than all the values / keys in the searched column.

public synchronized int
public synchronized int
getKey(int i)

public int[]
public synchronized long
private void
insertionSort(int lo0, int hi0)

protected boolean

Returns:

true or false
lessThan
(int
the first index
i
,
int
the second index
j
)

Check if row indexed i is less than row indexed j

protected void
moveAndInsertRow(int i, int j)

protected void
moveRows(int fromIndex, int toIndex, int rows)

private int
partition(int start, int end, int pivot)

private void
quickSort(int l, int r)

public final synchronized void
remove(int position)

public synchronized void
public synchronized int
removeFirstConsecutiveKeys(int
the number of consecutive keys required
number
,
int
default value
def
)

Returns: the first key in series or def if not found

public synchronized void
removeRange(int start, int limit)

public synchronized void
setKey(int
the index
i
,
int
the key
key
)

Modifies an existing pair.

public synchronized int
size()

public synchronized void
sort()

protected void
swap(int i1, int i2)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

capacityback to summary
private int capacity
countback to summary
private int count
fixedSizeback to summary
private final boolean fixedSize
keysback to summary
private int[] keys
sortedback to summary
private boolean sorted
targetSearchValueback to summary
private int targetSearchValue

Constructor Detail

IntIndexback to summary
public IntIndex(int capacity, boolean fixedSize)

Method Detail

addback to summary
public synchronized int add(int key)

Adds a key, maintaining sort order on current search target column.

Parameters
key:int

the key

Returns:int

index of added key or -1 if full

addSortedback to summary
public synchronized boolean addSorted(int key)

Adds a key into the table with the guarantee that the key is equal or larger than the largest existing key. This prevents a sort from taking place on next call to find()

Parameters
key:int

the key

Returns:boolean

true or false depending on success

addUniqueback to summary
public synchronized boolean addUnique(int key)

Adds a key, ensuring no duplicate key already exists in the current search target column.

Parameters
key:int

the key

Returns:boolean

true or false depending on success

addUnsortedback to summary
public synchronized boolean addUnsorted(int key)

Adds a key into the table.

Parameters
key:int

the key

Returns:boolean

true or false depending on success

binaryEmptySlotSearchback to summary
private int binaryEmptySlotSearch()

Returns the index of the lowest element > the given search target or count or -1 if target is found

Returns:int

the index

binaryFirstSearchback to summary
private int binaryFirstSearch()

Returns the index of the lowest element == the given search target, or -1

Returns:int

index or -1 if not found

binarySlotSearchback to summary
private int binarySlotSearch()

Returns the index of the lowest element >= the given search target, or count

Returns:int

the index

capacityback to summary
public synchronized int capacity()
clearback to summary
public void clear()
compareback to summary
protected int compare(int i)

Check if targeted column value in the row indexed i is less than the search target object.

Parameters
i:int

the index

Returns:int

-1, 0 or +1

doubleCapacityback to summary
protected void doubleCapacity()
fastQuickSortback to summary
private synchronized void fastQuickSort()

fast quicksort using a stack on the heap to reduce stack use

fastQuickSortRecursiveback to summary
private synchronized void fastQuickSortRecursive()

fast quicksort with recursive quicksort implementation

findFirstConsecutiveKeysback to summary
public synchronized int findFirstConsecutiveKeys(int number)
Parameters
number:int

the number of consecutive keys required

Returns:int

the index or -1 if not found

findFirstEqualKeyIndexback to summary
public synchronized int findFirstEqualKeyIndex(int value)
Parameters
value:int

the value

Returns:int

the index

findFirstGreaterEqualKeyIndexback to summary
public synchronized int findFirstGreaterEqualKeyIndex(int value)
Parameters
value:int

the value

Returns:int

the index

findFirstGreaterEqualSlotIndexback to summary
public synchronized int findFirstGreaterEqualSlotIndex(int value)

This method is similar to findFirstGreaterEqualKeyIndex(int) but returns the index of the empty row past the end of the array if the search value is larger than all the values / keys in the searched column.

Parameters
value:int

the value

Returns:int

the index

findFirstIndexUnsortedback to summary
public synchronized int findFirstIndexUnsorted(int value)
getKeyback to summary
public synchronized int getKey(int i)
getKeysback to summary
public int[] getKeys()
getTotalValuesback to summary
public synchronized long getTotalValues()
insertionSortback to summary
private void insertionSort(int lo0, int hi0)
lessThanback to summary
protected boolean lessThan(int i, int j)

Check if row indexed i is less than row indexed j

Parameters
i:int

the first index

j:int

the second index

Returns:boolean

true or false

moveAndInsertRowback to summary
protected void moveAndInsertRow(int i, int j)
moveRowsback to summary
protected void moveRows(int fromIndex, int toIndex, int rows)
partitionback to summary
private int partition(int start, int end, int pivot)
quickSortback to summary
private void quickSort(int l, int r)
removeback to summary
public final synchronized void remove(int position)
removeAllback to summary
public synchronized void removeAll()
removeFirstConsecutiveKeysback to summary
public synchronized int removeFirstConsecutiveKeys(int number, int def)
Parameters
number:int

the number of consecutive keys required

def:int

default value

Returns:int

the first key in series or def if not found

removeRangeback to summary
public synchronized void removeRange(int start, int limit)
setKeyback to summary
public synchronized void setKey(int i, int key)

Modifies an existing pair.

Parameters
i:int

the index

key:int

the key

sizeback to summary
public synchronized int size()
sortback to summary
public synchronized void sort()
swapback to summary
protected void swap(int i1, int i2)