Beispiel #1
0
        private Node <T, V> Find(Node <T, V> current, T key)
        {
            var compRes = comparator.compare(current.Key, key);

            return(compRes switch
            {
                -1 => current.ChildRight == null ? current : Find(current.ChildRight, key),
                0 => current,
                1 => current.ChildLeft == null ? current : Find(current.ChildLeft, key)
            });
Beispiel #2
0
        private void AddChild <T, V>(Node <T, V> parent, Node <T, V> child, StringComparator comparer)
        {
            var compRes = comparer.compare(parent.Key, child.Key);

            if (compRes < 0)
            {
                parent.ChildRight = child;
            }
            else
            {
                parent.ChildLeft = child;
            }
        }