Class: TokyoCabinet::BDBCUR [Tokyo Cabinet]

Class | TokyoCabinet::BDBCUR
In: | tokyocabinet-doc.rb
Parent: | Object

Cursor is a mechanism to access each record of B+ tree database in ascending or descending order.

### Methods

first jump key last new next out prev put val

### Constants

CPCURRENT | = | 0 |  | cursor put mode: current
CPBEFORE | = | 1 |  | cursor put mode: before
CPAFTER | = | 2 |  | cursor put mode: after

### Public Class methods

new(bdb)

Create a cursor object.
`bdb' specifies the B+ tree database object.
The return value is the new cursor object.
Note that the cursor is available only after initialization with the `first' or the `jump' methods and so on. Moreover, the position of the cursor will be indefinite when the database is updated after the initialization of the cursor.

### Public Instance methods

first()

Move the cursor to the first record.
If successful, the return value is true, else, it is false. False is returned if there is no record in the database.

jump(key)

Move the cursor to the front of records corresponding a key.
`key' specifies the key.
If successful, the return value is true, else, it is false. False is returned if there is no record corresponding the condition.
The cursor is set to the first record corresponding the key or the next substitute if completely matching record does not exist.

key()

Get the key of the record where the cursor is.
If successful, the return value is the key, else, it is `nil'. ‘nil' is returned when the cursor is at invalid position.

last()

Move the cursor to the last record.
If successful, the return value is true, else, it is false. False is returned if there is no record in the database.

next()

Move the cursor to the next record.
If successful, the return value is true, else, it is false. False is returned if there is no next record.

out()

Remove the record where the cursor is.
If successful, the return value is true, else, it is false. False is returned when the cursor is at invalid position.
After deletion, the cursor is moved to the next record if possible.

prev()

Move the cursor to the previous record.
If successful, the return value is true, else, it is false. False is returned if there is no previous record.

put(value, cpmode)

Insert a record around the cursor.
`value' specifies the value.
`cpmode' specifies detail adjustment: `TokyoCabinet::BDBCUR::CPCURRENT', which means that the value of the current record is overwritten, `TokyoCabinet::BDBCUR::CPBEFORE', which means that the new record is inserted before the current record, `TokyoCabinet::BDBCUR::CPAFTER', which means that the new record is inserted after the current record.
If successful, the return value is true, else, it is false. False is returned when the cursor is at invalid position.
After insertion, the cursor is moved to the inserted record.

val()

Get the value of the record where the cursor is.
If successful, the return value is the value, else, it is `nil'. ‘nil' is returned when the cursor is at invalid position.