aboutsummaryrefslogtreecommitdiff
path: root/node.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-02-03 14:33:51 -0700
committerBen Johnson <benbjohnson@yahoo.com>2014-02-03 14:33:51 -0700
commit0cae98efc5fd76f0f5159b6615f29ccf8bf97aa8 (patch)
tree96120044d92bcfbcbf5258bdf9c334448fc55aa7 /node.go
parentMerge pull request #5 from benbjohnson/put (diff)
downloaddedo-0cae98efc5fd76f0f5159b6615f29ccf8bf97aa8.tar.gz
dedo-0cae98efc5fd76f0f5159b6615f29ccf8bf97aa8.tar.xz
Add RWTransaction.Delete().
Diffstat (limited to 'node.go')
-rw-r--r--node.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/node.go b/node.go
index 8d03681..2b3fded 100644
--- a/node.go
+++ b/node.go
@@ -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