Esempio n. 1
0
        public void ShouldNotRemoveNotExistingIntervalFromTree()
        {
            var intervalNodeFour  = new IntervalWithValue <long, long>(0, 5, 1);
            var intervalNodeFive  = new IntervalWithValue <long, long>(10, 15, 2);
            var intervalNodeSix   = new IntervalWithValue <long, long>(20, 25, 0);
            var intervalNodeSeven = new IntervalWithValue <long, long>(30, 35, 0);
            var intervalNodeTwo   = new IntervalWithValue <long, long>(5, 10, 1);
            var intervalNodeThree = new IntervalWithValue <long, long>(25, 30, 2);
            var intervalNodeOne   = new IntervalWithValue <long, long>(15, 20, 0);
            var treeIntervals     = new List <IntervalWithValue <long, long> >
            {
                intervalNodeOne, intervalNodeTwo, intervalNodeThree, intervalNodeFour, intervalNodeFive,
                intervalNodeSix, intervalNodeSeven
            };
            var tree = new MutableIntervalBalancedTree <long, long>(treeIntervals);

            Assert.False(tree.Remove(new IntervalWithValue <long, long>(115, 120, 0)));
            Assert.Equal(7, tree.Count);
        }
Esempio n. 2
0
        public void ShouldRemoveCorrectlyIntervalFromTree()
        {
            var intervalNodeFour  = new IntervalWithValue <long, long>(0, 5, 1);
            var intervalNodeFive  = new IntervalWithValue <long, long>(10, 15, 2);
            var intervalNodeSix   = new IntervalWithValue <long, long>(20, 25, 0);
            var intervalNodeSeven = new IntervalWithValue <long, long>(30, 35, 0);
            var intervalNodeTwo   = new IntervalWithValue <long, long>(5, 10, 1);
            var intervalNodeThree = new IntervalWithValue <long, long>(25, 30, 2);
            var intervalNodeOne   = new IntervalWithValue <long, long>(15, 20, 0);
            var treeIntervals     = new List <IntervalWithValue <long, long> >
            {
                intervalNodeOne, intervalNodeTwo, intervalNodeThree, intervalNodeFour, intervalNodeFive,
                intervalNodeSix, intervalNodeSeven
            };
            var tree = new MutableIntervalBalancedTree <long, long>(treeIntervals);

            Assert.True(tree.Remove(new IntervalWithValue <long, long>(15, 20, 0)));
            Assert.Equal(6, tree.Count);
            Assert.DoesNotContain(new IntervalWithValue <long, long>(15, 20, 0), tree);
        }
Esempio n. 3
0
        public void ShouldReturnFalseOnRemoveOnEmptyTree()
        {
            var tree = new MutableIntervalBalancedTree <long, long>(new List <IntervalWithValue <long, long> >());

            Assert.False(tree.Remove(new IntervalWithValue <long, long>(115, 120, 0)));
        }