aboutsummaryrefslogtreecommitdiff
path: root/core/container
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2024-05-24 13:58:30 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2024-05-24 13:58:30 +0200
commit11e57fd3fd290c1237f33e83f0142b3d98a7e2d9 (patch)
treea74b04c58953c4a63438c61638722aa6f5e15454 /core/container
parentc43d189a3353637b416571b90cab3bc8aa0aaf87 (diff)
Address concerns.
Diffstat (limited to 'core/container')
-rw-r--r--core/container/rbtree/rbtree.odin9
1 files changed, 5 insertions, 4 deletions
diff --git a/core/container/rbtree/rbtree.odin b/core/container/rbtree/rbtree.odin
index 26cce46b4..8ab131b3b 100644
--- a/core/container/rbtree/rbtree.odin
+++ b/core/container/rbtree/rbtree.odin
@@ -131,7 +131,7 @@ find_value :: proc(t: ^$T/Tree($Key, $Value), key: Key) -> (value: Value, ok: bo
// find_or_insert attempts to insert the value into the tree, and returns
// the node, a boolean indicating if the value was inserted, and the
// node allocator error if relevant. If the value is already present, the existing node is updated.
-find_or_insert :: proc(t: ^$T/Tree($Key, $Value), key: Key, value: Value) -> (n: ^Node(Key, Value), inserted: bool) {
+find_or_insert :: proc(t: ^$T/Tree($Key, $Value), key: Key, value: Value) -> (n: ^Node(Key, Value), inserted: bool, err: runtime.Allocator_Error) {
n_ptr := &t._root
for n_ptr^ != nil {
n = n_ptr^
@@ -145,11 +145,12 @@ find_or_insert :: proc(t: ^$T/Tree($Key, $Value), key: Key, value: Value) -> (n:
}
}
_parent := n
- n = new_clone(Node(Key, Value){key=key, value=value, _parent=_parent, _color=.Red}, t._node_allocator) // or_return
+
+ n = new_clone(Node(Key, Value){key=key, value=value, _parent=_parent, _color=.Red}, t._node_allocator) or_return
n_ptr^ = n
insert_case1(t, n)
t._size += 1
- return n, true
+ return n, true, nil
}
// remove removes a node or value from the tree, and returns true iff the
@@ -208,7 +209,7 @@ remove_node :: proc(t: ^$T/Tree($Key, $Value), node: ^$N/Node(Key, Value), call_
// iterator returns a tree iterator in the specified direction.
iterator :: proc "contextless" (t: ^$T/Tree($Key, $Value), direction: Direction) -> Iterator(Key, Value) {
it: Iterator(Key, Value)
- it._tree = transmute(^Tree(Key, Value))t
+ it._tree = cast(^Tree(Key, Value))t
it._direction = direction
iterator_first(&it)