Example #1
0
 public Assoc(TKey key, TValue value, Assoc <TKey, TValue> tail)
 {
     Key   = key;
     Value = value;
     Count = tail.Count + 1;
     Tail  = tail;
 }
Example #2
0
 Assoc()
 {
     Key   = default(TKey);
     Value = default(TValue);
     Count = 0;
     Tail  = this;
 }
Example #3
0
            public Assoc <TKey, TValue> Update(Assoc <TKey, TValue> source, out bool replaced, out bool mutated)
            {
                var newAssoc = source.TryRemove(Key, out mutated, out Value);

                if (!mutated)
                {
                    replaced = false;
                    return(default(Assoc <TKey, TValue>));
                }

                CountChanged--;
                replaced = !newAssoc.IsEmpty;
                return(newAssoc);
            }
Example #4
0
 public Assoc <TKey, TValue> Update(Assoc <TKey, TValue> source, out bool replaced, out bool mutated)
 {
     replaced = true;
     mutated  = true;
     return(source.SetOrAdd(Key, Value, out CountChanged));
 }
Example #5
0
 public Assoc <TKey, TValue> Create(out bool mutated)
 {
     mutated = true;
     return(Assoc.Empty <TKey, TValue>().SetOrAdd(Key, Value, out CountChanged));
 }