示例#1
0
        /// <summary>
        /// Finds object(s) in the set.
        /// </summary>
        /// <returns>Collection of objects equal to <b>obj</b>.</returns>
        /// <remarks>
        /// If no elements equal to <b>obj</b> are found in the set, returns
        /// valid reference to an empty collection.
        /// </remarks>
        public System.Collections.ICollection FindAll(object key)
        {
            System.Collections.ArrayList result = new System.Collections.ArrayList();
            if (key == null)
            {
                return(result);
            }

            RbTreeNode lower = _tree.LowerBound(key);
            RbTreeNode upper = _tree.UpperBound(key);

            if (lower == upper)
            {
                return(result);
            }

            for (RbTreeNode node = lower; node != upper; node = _tree.Next(node))
            {
                result.Add(node.Value);
            }

            return(result);
        }
示例#2
0
        /// <summary>
        /// Finds object(s) in the set.
        /// </summary>
        /// <returns>Collection of objects equal to <b>obj</b>.</returns>
        /// <remarks>
        /// If no elements equal to <b>obj</b> are found in the set, returns
        /// valid reference to an empty collection.
        /// </remarks>
        public ICollection FindAll(object key)
        {
            var result = new ArrayList();

            if (key == null)
            {
                return(result);
            }

            var lower = _tree.LowerBound(key);
            var upper = _tree.UpperBound(key);

            if (lower == upper)
            {
                return(result);
            }

            for (var node = lower; node != upper; node = _tree.Next(node))
            {
                result.Add(node.Value);
            }

            return(result);
        }