diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-03 14:33:51 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-03 14:33:51 -0700 |
commit | 0cae98efc5fd76f0f5159b6615f29ccf8bf97aa8 (patch) | |
tree | 96120044d92bcfbcbf5258bdf9c334448fc55aa7 /node.go | |
parent | Merge pull request #5 from benbjohnson/put (diff) | |
download | dedo-0cae98efc5fd76f0f5159b6615f29ccf8bf97aa8.tar.gz dedo-0cae98efc5fd76f0f5159b6615f29ccf8bf97aa8.tar.xz |
Add RWTransaction.Delete().
Diffstat (limited to 'node.go')
-rw-r--r-- | node.go | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -61,6 +61,20 @@ func (n *node) put(oldKey, newKey, value []byte, pgid pgid) { inode.pgid = pgid } +// del removes a key from the node. +func (n *node) del(key []byte) { + // Find index of key. + index := sort.Search(len(n.inodes), func(i int) bool { return bytes.Compare(n.inodes[i].key, key) != -1 }) + + // Exit if the key isn't found. + if !bytes.Equal(n.inodes[index].key, key) { + return + } + + // Delete inode from the node. + n.inodes = append(n.inodes[:index], n.inodes[index+1:]...) +} + // read initializes the node from a page. func (n *node) read(p *page) { n.pgid = p.id |