/// <summary> /// Returns a dictionary with the same keys. For each key in the dictionary, the /// value is obtained by calling <code>func(key, this[key])</code>. /// </summary> /// <param name="func">The function mapped.</param> /// <returns>The resulting dictionary.</returns> public TreeDictionary <TKey, TValue, TComparer> Map(Func <TKey, TValue, TValue> func) { if (Count == 0) { return(this); } return(Balanced( func(_key, _value), _left.Map(func), _right.Map(func))); }