Top Description Fields Constructors Methods
org.hsqldb.lib

public final Class DoubleLongIndex

extends Object
implements LongLookup
Class Inheritance
All Implemented Interfaces
org.hsqldb.lib.LongLookup
Imports
java.util.Arrays, .NoSuchElementException

Maintains an ordered long->long lookup table, consisting of two columns, one for keys, the other for values. Equal keys are allowed.

The table is sorted on key column.

findXXX() methods return the array index into the list pair containing a matching key or value, or -1 if not found.

Based on org.hsqldb.lib.DoubleIntIndex

Author
Fred Toussi (fredt@users dot sourceforge.net)
Since
1.8.0
Version
2.7.3

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
DoubleLongIndex(int capacity)

Method Summary

Modifier and TypeMethod and Description
public int
add(long key, long value)

Implements org.hsqldb.lib.LongLookup.add.

public boolean
addUnsorted(long key, long value)

Implements org.hsqldb.lib.LongLookup.addUnsorted.

public boolean
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 or count
binarySlotSearch
(boolean
ignored
fullCompare
)

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

public void
public boolean
private 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.

public void
private void
public LongLookup
private boolean
private void
fastQuickSort()

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

private void
fastQuickSortRecursive()

fast quicksort with recursive quicksort implementation

public int
findFirstEqualKeyIndex(long
the value
value
)

Returns: the index

public int
findFirstGreaterEqualKeyIndex(long
the value
value
)

Returns: the index

public int

Returns:

the index
findFirstGreaterEqualSlotIndex
(long
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 long
public long
public long
private void
insertionSort(int lo0, int hi0)

private 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

public long
public long
lookup(long key, long def)

Implements org.hsqldb.lib.LongLookup.lookup.

private void
moveAndInsertRow(int i, int j)

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

private int
partition(int start, int end)

private void
quickSort(int l, int r)

public void
setLongValue(int
the index
i
,
long
the value
value
)

Implements org.hsqldb.lib.LongLookup.setLongValue.

Modifies an existing pair.

public void
setSize(int newSize)

public int
public void
private 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
keysback to summary
private long[] keys
sortedback to summary
private boolean sorted
targetSearchValueback to summary
private long targetSearchValue
valuesback to summary
private long[] values

Constructor Detail

DoubleLongIndexback to summary
public DoubleLongIndex(int capacity)

Method Detail

addback to summary
public int add(long key, long value)

Implements org.hsqldb.lib.LongLookup.add.

addUnsortedback to summary
public boolean addUnsorted(long key, long value)

Implements org.hsqldb.lib.LongLookup.addUnsorted.

addUnsortedback to summary
public boolean addUnsorted(LongLookup other)

Implements org.hsqldb.lib.LongLookup.addUnsorted.

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(boolean fullCompare)

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

Parameters
fullCompare:boolean

ignored

Returns:int

the index or count

clearback to summary
public void clear()

Implements org.hsqldb.lib.LongLookup.clear.

compactLookupAsIntervalsback to summary
public boolean compactLookupAsIntervals()

Implements org.hsqldb.lib.LongLookup.compactLookupAsIntervals.

compareback to summary
private 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

copyToback to summary
public void copyTo(DoubleLongIndex other)
doubleCapacityback to summary
private void doubleCapacity()
duplicateback to summary
public LongLookup duplicate()

Implements org.hsqldb.lib.LongLookup.duplicate.

ensureCapacityToAddback to summary
private boolean ensureCapacityToAdd(int extra)
fastQuickSortback to summary
private void fastQuickSort()

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

fastQuickSortRecursiveback to summary
private void fastQuickSortRecursive()

fast quicksort with recursive quicksort implementation

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

the value

Returns:int

the index

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

the value

Returns:int

the index

findFirstGreaterEqualSlotIndexback to summary
public int findFirstGreaterEqualSlotIndex(long 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:long

the value

Returns:int

the index

getLongKeyback to summary
public long getLongKey(int i)

Implements org.hsqldb.lib.LongLookup.getLongKey.

getLongValueback to summary
public long getLongValue(int i)

Implements org.hsqldb.lib.LongLookup.getLongValue.

getTotalValuesback to summary
public long getTotalValues()

Implements org.hsqldb.lib.LongLookup.getTotalValues.

insertionSortback to summary
private void insertionSort(int lo0, int hi0)
lessThanback to summary
private 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

lookupback to summary
public long lookup(long key) throws NoSuchElementException

Implements org.hsqldb.lib.LongLookup.lookup.

lookupback to summary
public long lookup(long key, long def)

Implements org.hsqldb.lib.LongLookup.lookup.

moveAndInsertRowback to summary
private void moveAndInsertRow(int i, int j)
moveRowsback to summary
private void moveRows(int fromIndex, int toIndex, int rows)
partitionback to summary
private int partition(int start, int end)
quickSortback to summary
private void quickSort(int l, int r)
setLongValueback to summary
public void setLongValue(int i, long value)

Implements org.hsqldb.lib.LongLookup.setLongValue.

Modifies an existing pair.

Parameters
i:int

the index

value:long

the value

setSizeback to summary
public void setSize(int newSize)
sizeback to summary
public int size()

Implements org.hsqldb.lib.LongLookup.size.

sortback to summary
public void sort()

Implements org.hsqldb.lib.LongLookup.sort.

swapback to summary
private void swap(int i1, int i2)