From 6787c1817f45d0bfa3cc4e2a9c9cf6b8141f6404 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Fri, 8 Aug 2025 12:06:51 +0800 Subject: [PATCH] change key types to any --- tree.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tree.go b/tree.go index bf0be38..9d3d38c 100644 --- a/tree.go +++ b/tree.go @@ -5,7 +5,7 @@ import ( ) // Node is a node on the binary search tree. -type Node[K comparable, V any, C Sorter[K]] struct { +type Node[K, V any, C Sorter[K]] struct { lson, rson *Node[K, V, C] parent *Node[K, V, C] bal uint32 // for treap balancing @@ -23,7 +23,7 @@ func (n *Node[K, V, C]) Key() K { // addresses and don't work with values. // // The zero value is a usable, empty tree. -type Tree[K comparable, V any, C Sorter[K]] struct { +type Tree[K, V any, C Sorter[K]] struct { root *Node[K, V, C] } @@ -58,6 +58,8 @@ func (t *Tree[K, V, C]) InsertNode(key K, value V) (node *Node[K, V, C], is_adde // realInsertNode recursivly searches and tries to insert the new node. // If the key is found, it's passed into *result. +// +// Returns the new node that should be placed in CUR's place (usually itself). func (t *Tree[K, V, C]) realInsertNode(cur, parent *Node[K, V, C], key K, value V, result **Node[K, V, C], is_added *bool) (node *Node[K, V, C]) { var c C if cur == nil {