Top Description Fields Constructors Methods
org.h2.mvstore

public final Class Cursor<K, V>

extends Object
implements Iterator<K>
Class Inheritance
All Implemented Interfaces
java.util.Iterator
Type Parameters
<K>
the key type
<V>
the value type
Imports
java.util.Iterator, .NoSuchElementException

A cursor to iterate over elements in ascending or descending order.

Field Summary

Modifier and TypeField and Description
private K
private CursorPos<K, V>
private CursorPos<K, V>
private K
private Page<K, V>
private V
private final boolean
private final K

Constructor Summary

AccessConstructor and Description
public
Cursor(RootReference<K, V> rootReference, K from, K to)

public
Cursor(RootReference<K, V>
of the tree
rootReference
,
K
starting key (inclusive), if null start from the first / last key
from
,
K
ending key (inclusive), if null there is no boundary
to
,
boolean
true if tree should be iterated in key's descending order
reverse
)

Method Summary

Modifier and TypeMethod and Description
public K

Returns:

the key or null
getKey
()

Get the last read key if there was one.

pack-priv Page<K, V>

Returns:

the page
getPage
()

Get the page where last retrieved key is located.

public V

Returns:

the value or null
getValue
()

Get the last read value if there was one.

public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public K
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public void
skip(long
the number of entries to skip
n
)

Skip over that many entries.

pack-priv static <
key type
K
,
value type
V
>
CursorPos<K, V>

Returns:

CursorPos representing path from the entry found, or from insertion point if not, all the way up to to the root page provided
traverseDown
(Page<K, V>
to start from as a root
page
,
K
to search for, null means search for the first available key
key
,
boolean
true if traversal is in reverse direction, false otherwise
reverse
)

Fetch the next entry that is equal or larger than the given key, starting from the given page.

private static <K, V> int
upperBound(Page<K, V> page)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
private K current
cursorPosback to summary
private CursorPos<K, V> cursorPos
keeperback to summary
private CursorPos<K, V> keeper
lastback to summary
private K last
lastPageback to summary
private Page<K, V> lastPage
lastValueback to summary
private V lastValue
reverseback to summary
private final boolean reverse
toback to summary
private final K to

Constructor Detail

Cursorback to summary
public Cursor(RootReference<K, V> rootReference, K from, K to)
Cursorback to summary
public Cursor(RootReference<K, V> rootReference, K from, K to, boolean reverse)
Parameters
rootReference:RootReference<K, V>

of the tree

from:K

starting key (inclusive), if null start from the first / last key

to:K

ending key (inclusive), if null there is no boundary

reverse:boolean

true if tree should be iterated in key's descending order

Method Detail

getKeyback to summary
public K getKey()

Get the last read key if there was one.

Returns:K

the key or null

getPageback to summary
pack-priv Page<K, V> getPage()

Get the page where last retrieved key is located.

Returns:Page<K, V>

the page

Annotations
@SuppressWarnings:unused
getValueback to summary
public V getValue()

Get the last read value if there was one.

Returns:V

the value or null

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public K next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:K

the next element in the iteration

Annotations
@Override
skipback to summary
public void skip(long n)

Skip over that many entries. This method is relatively fast (for this map implementation) even if many entries need to be skipped.

Parameters
n:long

the number of entries to skip

traverseDownback to summary
pack-priv static <K, V> CursorPos<K, V> traverseDown(Page<K, V> page, K key, boolean reverse)

Fetch the next entry that is equal or larger than the given key, starting from the given page. This method returns the path.

Parameters
<K>
key type
<V>
value type
page:Page<K, V>

to start from as a root

key:K

to search for, null means search for the first available key

reverse:boolean

true if traversal is in reverse direction, false otherwise

Returns:CursorPos<K, V>

CursorPos representing path from the entry found, or from insertion point if not, all the way up to to the root page provided

upperBoundback to summary
private static <K, V> int upperBound(Page<K, V> page)