public object Clone() { var result = new AVL_Tree <T>(); foreach (var item in this) { result.Add(item); } return(result); }
/// <summary> /// Adds an element with the provided key and value to the <see cref="T:System.Collections.Generic.IDictionary`2" />. /// </summary> /// <param name="key">The object to use as the key of the element to add.</param> /// <param name="value">The object to use as the value of the element to add.</param> /// <exception cref="T:System.ArgumentNullException"><paramref name="key" /> is null.</exception> /// <exception cref="T:System.ArgumentException">An element with the same key already exists in the <see cref="T:System.Collections.Generic.IDictionary`2" />.</exception> /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.IDictionary`2" /> is read-only.</exception> public void Add(TKey key, TValue value) { // ReSharper disable CompareNonConstrainedGenericWithNull if (key == null) { // ReSharper restore CompareNonConstrainedGenericWithNull throw new ArgumentNullException(); } if (ContainsKey(key)) { throw new ArgumentException(); } keyCollection.Add(new Pair <TKey, TValue> { Key = key, Value = value }); }