예제 #1
0
 public Assoc(TKey key, TValue value, Assoc <TKey, TValue> tail)
 {
     Key   = key;
     Value = value;
     Count = tail.Count + 1;
     Tail  = tail;
 }
예제 #2
0
 Assoc()
 {
     Key   = default(TKey);
     Value = default(TValue);
     Count = 0;
     Tail  = this;
 }
예제 #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);
            }
예제 #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));
 }
예제 #5
0
 public Assoc <TKey, TValue> Create(out bool mutated)
 {
     mutated = true;
     return(Assoc.Empty <TKey, TValue>().SetOrAdd(Key, Value, out CountChanged));
 }