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);
        }
Example #2
0
 public SortedMapSeq(RedBlackNode t, bool asc, int count) :
     this(Push(t, null, asc), asc, count)
 {
 }
Example #3
0
 protected internal virtual RedBlackNode BalanceRight(RedBlackNode parent) => SortedMap.MakeBlack(parent.Key, parent.Value, parent.Left, this);
Example #4
0
 protected internal abstract RedBlackNode Replace(object key, object val, RedBlackNode left, RedBlackNode right);
Example #5
0
 protected internal abstract RedBlackNode RemoveRight(RedBlackNode delete);
Example #6
0
 protected internal abstract RedBlackNode AddRight(RedBlackNode insert);
Example #7
0
 protected internal override RedBlackNode Replace(object key, object val, RedBlackNode left, RedBlackNode right) => SortedMap.MakeRed(key, val, left, right);
Example #8
0
 protected internal override RedBlackNode RemoveRight(RedBlackNode delete) => SortedMap.MakeRed(this._key, Value, Left, delete);
Example #9
0
 protected internal override RedBlackNode AddRight(RedBlackNode insert) => SortedMap.MakeRed(this._key, Value, Left, insert);
 public TransientSortedMap(AtomicReference <Thread> edit, System.Collections.IComparer comp, RedBlackNode tree, int count)
 {
     this._edit  = edit;
     this._comp  = comp;
     this._tree  = tree;
     this._count = count;
 }