Ejemplo n.º 1
0
        protected override ITransientMap DoAssoc(object key, object val)
        {
            var found = new Box(null);
            var t     = SortedMap.Add(this._comp, this._tree, key, val, found);

            if (t is null)
            {
                var foundNode = found.Value as RedBlackNode;
                if (foundNode.Value == val)
                {
                    return(this);
                }

                this._tree = SortedMap.Replace(this._comp, this._tree, key, val);
                return(this);
            }

            this._tree = t.Blacken();
            this._count++;
            return(this);
        }