summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2020-10-16 09:35:52 +0100
committerPaul Buetow <paul@buetow.org>2020-10-16 09:35:52 +0100
commitf0828a8336a4404b8a9807c4aaf6313f4ff8c5e8 (patch)
tree174ff8288ef19fe707870c73ce123698596f0bba
parent66c129c089dee23b03d1bb7850cbd82113c63cdb (diff)
more on tree
-rw-r--r--set/tree.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/set/tree.go b/set/tree.go
index d4f7b7d..8233b0e 100644
--- a/set/tree.go
+++ b/set/tree.go
@@ -66,7 +66,16 @@ func (t *Tree) Get(key int) (int, error) {
return t.get(t.root, key)
}
-/*
- Get(key int) (int, error)
- Del(key int) (int, error)
-*/
+func (t *Tree) Del(key int) (int, error) {
+ if t.root == nil {
+ return 0, NotFound
+ }
+
+ if t.root.key == key {
+ val := t.root.val
+
+ return val, nil
+ }
+
+ return 0, NotImplemented
+}