First moves the cursor to the first item in the bucket and returns its key and value. If the bucket is empty then a nil key and value are returned. The returned key and value are only valid for the life of the transaction.
()
| 33 | // If the bucket is empty then a nil key and value are returned. |
| 34 | // The returned key and value are only valid for the life of the transaction. |
| 35 | func (c *Cursor) First() (key []byte, value []byte) { |
| 36 | common.Assert(c.bucket.tx.db != nil, "tx closed") |
| 37 | k, v, flags := c.first() |
| 38 | if (flags & uint32(common.BucketLeafFlag)) != 0 { |
| 39 | return k, nil |
| 40 | } |
| 41 | return k, v |
| 42 | } |
| 43 | |
| 44 | func (c *Cursor) first() (key []byte, value []byte, flags uint32) { |
| 45 | c.stack = c.stack[:0] |