Exemple #1
0
 private TreeDictionary <TKey, TValue, TComparer> UnionTrim(
     TreeDictionary <TKey, TValue, TComparer> otherDict,
     TKey low, TKey high,
     Func <TKey, TValue, TValue, TValue> combiner)
 {
     if (otherDict.Count == 0)
     {
         return(this);
     }
     if (Count == 0)
     {
         var otherLeft  = otherDict._left.FilterLess(high);
         var otherRight = otherDict._right.FilterGreater(low);
         return(ReferenceEquals(otherDict._left, otherLeft) && ReferenceEquals(otherDict._right, otherRight)
                    ? otherDict
                    : otherDict.Unbalanced(otherDict._value, otherLeft, otherRight));
     }
     Debug.Assert(_Comparer.Compare(low, _key) < 0 && _Comparer.Compare(high, _key) > 0);
     return(Unbalanced(
                _value,
                _left.UnionTrim(otherDict.Trim(low, _key), low, _key, combiner),
                _right.UnionTrim(otherDict.Trim(_key, high), _key, high, combiner)));
 }