Package org.h2.mvstore

# Class Cursor<K,V>

java.lang.Object
org.h2.mvstore.Cursor<K,V>

Type Parameters:
  `K` - the key type
  `V` - the value type

All Implemented Interfaces:
  `Iterator<K>`

public final class Cursor<K,V> extends Object implements Iterator<K>
A cursor to iterate over elements in ascending or descending order.

## Constructor Summary

Constructors
Constructor
Description
`Cursor(RootReference<K,V> rootReference, K from, K to)`
`Cursor(RootReference<K,V> rootReference, K from, K to, boolean reverse)`

## Method Summary

Modifier and Type
Method
Description
`K`
`getKey()`
Get the last read key if there was one.
`V`
`getValue()`
Get the last read value if there was one.
`boolean`
`hasNext()`
`K`
`next()`
`void`
`skip(long n)`
Skip over that many entries.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.util.Iterator

`forEachRemaining, remove`

## Constructor Details

### Cursor

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

### Cursor

public Cursor(RootReference<K,V> rootReference, K from, K to, boolean reverse)

Parameters:
  `rootReference` - of the tree
  `from` - starting key (inclusive), if null start from the first / last key
  `to` - ending key (inclusive), if null there is no boundary
  `reverse` - true if tree should be iterated in key's descending order

## Method Details

### hasNext

public boolean hasNext()

Specified by:
  `hasNext` in interface `Iterator<K>`

### next

public K next()

Specified by:
  `next` in interface `Iterator<K>`

### getKey

public K getKey()
Get the last read key if there was one.

Returns:
  the key or null

### getValue

public V getValue()
Get the last read value if there was one.

Returns:
  the value or null

### skip

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` - the number of entries to skip