Пример #1
0
        internal RangeTreeNode <T> Find(T value)
        {
            var result = tree.FindNode(new RangeTreeNode <T>(value));

            if (result == null)
            {
                throw new Exception("Item not found in this tree.");
            }

            return(result.Value);
        }
 //O(log(n) time complexity;
 public TV GetValue(TK key)
 {
     return(binarySearchTree
            .FindNode(new TreeDictionaryNode <TK, TV>(key, default(TV)))
            .Value
            .Value);
 }
Пример #3
0
        /// <summary>
        /// Insert a new Interval.
        /// </summary>
        internal void Insert(OneDimentionalInterval <T> newInterval)
        {
            sortInterval(newInterval);
            var existing = redBlackTree.FindNode(newInterval);

            if (existing != null)
            {
                existing.Value.End.Add(newInterval.End[0]);
            }
            else
            {
                existing = redBlackTree.InsertAndReturnNode(newInterval).Item1;
            }
            updateMax(existing);
            Count++;
        }