Esempio n. 1
0
        /// <summary>
        /// Adds a new item to the set, or does nothing if the item already exists.
        /// </summary>
        /// <param name="item">The item to add.</param>
        /// <returns></returns>
        public override ImmSortedSet <T> Add(T item)
        {
            var ret = Root.Root_Add(item, true, Comparer, false, Lineage.Mutable());

            if (ret == null)
            {
                return(this);
            }
            return(ret.Wrap(Comparer));
        }
Esempio n. 2
0
            public bool Add(T item)
            {
                var ret = _inner.Root_Add(item, true, _comparer, false, _lineage);

                if (ret == null)
                {
                    return(false);
                }
                _inner = ret;
                return(true);
            }
Esempio n. 3
0
        protected override ImmSortedMap <TKey, TValue> Set(TKey key, TValue value, bool overwrite)
        {
            var ret = Root.Root_Add(key, value, Comparer, overwrite, Lineage.Mutable());

            if (ret == null && !overwrite)
            {
                throw Errors.Key_exists(key);
            }
            if (ret == null)
            {
                return(this);
            }
            return(ret.WrapMap(Comparer));
        }
Esempio n. 4
0
 public bool Add(KeyValuePair <TKey, TValue> item)
 {
     _inner = _inner.Root_Add(item.Key, item.Value, _comparer, true, _lineage) ?? _inner;
     return(true);
 }