Пример #1
0
        public IDictionary <TKey, TValue> Merge <TKey, TValue>(IDictionary <TKey, TValue> mine,
                                                               IDictionary <TKey, TValue> original,
                                                               IDictionary <TKey, TValue> theirs,
                                                               MergeFunc <TValue> mergeFunc)
        {
            var result = new Dictionary <TKey, TValue>(theirs);

            foreach (var entry in mine.Except(original))
            {
                TValue theirValue;
                if (result.TryGetValue(entry.Key, out theirValue))
                {
                    TValue originalValue;
                    original.TryGetValue(entry.Key, out originalValue);
                    result[entry.Key] = mergeFunc(entry.Value, originalValue, theirValue);
                }
            }
            foreach (var key in original.Keys.Except(mine.Keys))
            {
                result.Remove(key);
            }
            return(result);
        }
Пример #2
0
 public AtomMerger(LispMissing missingSymbols, MergeFunc mergeAtom)
 {
     MissingSymbols = missingSymbols;
     MergeAtom      = mergeAtom;
 }