Пример #1
0
        /// <summary>
        /// Adds object to the set, preserving order.
        /// </summary>
        public bool Add(object key)
        {
            if (key == null)
            {
                return(false);
            }

            RbTree.InsertResult result = _tree.Insert(key, _allowDuplicates, true);

            if (result.NewNode)
            {
                ++_count;
            }
            return(result.NewNode);
        }
Пример #2
0
        /// <summary>
        /// Adds object to the set only if the set contains no equal object(s).
        /// </summary>
        public bool AddIfNotContains(object key)
        {
            if (key == null)
            {
                return(false);
            }

            RbTree.InsertResult result = _tree.Insert(key, false, false);

            if (result.NewNode)
            {
                ++_count;
            }

            return(result.NewNode);
        }