Example #1
0
        public static ITwoThree <T> Insert <T>(this ITwoThree <T> root, T item, IComparer <T> comparer = null)
        {
            comparer = comparer ?? Comparer <T> .Default;

            T             propagated;
            ITwoThree <T> left, right;
            var           node = root.Insert(item, comparer, out left, out right, out propagated);

            return(node ?? new TwoNode <T>(propagated, left, right));
        }
        public ImmutableSortedSet <T> Add(T item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            var newRoot = _root.Insert(item, _comparer);

            return(new ImmutableSortedSet <T>(newRoot, _comparer));
        }
        public ImmutableSortedDictionary <TKey, TValue> Add(KeyValuePair <TKey, TValue> item)
        {
            if (item.Key == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            var newRoot = _root.Insert(item, _comparer);

            if (newRoot == _root)
            {
                throw ExceptionHelper.GetKeyAlreadyExistsException(item.Key, "item");
            }

            return(new ImmutableSortedDictionary <TKey, TValue>(newRoot, _comparer));
        }