Exemple #1
0
        static void Main(string[] args)
        {
            AvlTree AVL = new AvlTree();

            AVL.Insert(5);
            AVL.Insert(4);
            AVL.Insert(3);
            AVL.Insert(2);
            AVL.Insert(1);
            AVL.PreOrder();

            AVL.Delete(3);
            AVL.Delete(1);
            AVL.PreOrder();

            AVL.Clear();

            AVL.Insert(1);
            AVL.Insert(2);
            AVL.Insert(3);
            AVL.Insert(4);
            AVL.Insert(5);
            AVL.PreOrder();

            AVL.Delete(5);
            AVL.Delete(1);
            AVL.Delete(3);
            AVL.PreOrder();

            AVL.Clear();

            AVL.Insert(1);
            AVL.Insert(4);
            AVL.Insert(2);
            AVL.Insert(3);
            AVL.Insert(9999);
            AVL.Insert(5);
            AVL.Insert(12);
            AVL.Insert(654);
            AVL.Insert(21);
            AVL.Insert(63);
            AVL.PreOrder();

            AVL.Delete(5);
            AVL.Delete(1);
            AVL.Delete(654);
            AVL.Insert(111);
            AVL.Delete(63);
            AVL.Delete(4);
            AVL.PreOrder();
            AVL.Delete(21);
            AVL.Insert(435);
            AVL.PreOrder();
            AVL.Delete(12);
            AVL.Delete(41);
            AVL.PreOrder();

            Console.ReadKey();
            AVL.Clear();
        }
Exemple #2
0
 public void ClearTest()
 {
     AvlTree<int> actual = new AvlTree<int> { 1,3,5,6,9,7 };
     Assert.AreEqual(6, actual.Count);
     actual.Clear();
     Assert.AreEqual(0, actual.Count);
 }
Exemple #3
0
 public void ClearPUT([PexAssumeUnderTest]List<int> values)
 {
     AvlTree<int> actual = new AvlTree<int>(values);
     PexAssert.AreEqual(values.Count, actual.Count);
     actual.Clear();
     PexAssert.AreEqual(0, actual.Count);
 }
Exemple #4
0
 void Clear()
 {
     if (tree != null)
     {
         tree.Clear();
     }
 }
Exemple #5
0
        public void AvlTreeOperationsTest()
        {
            String value;
            AvlTree <Int32, String> tree = new AvlTree <Int32, String>();

            foreach (KeyValuePair <Int32, String> keyValuePair in this.values)
            {
                tree.Insert(keyValuePair.Key, keyValuePair.Value);
            }

            tree.Count.ShouldBe(this.values.Length);

            foreach (KeyValuePair <Int32, String> keyValuePair in this.values)
            {
                tree.Contains(keyValuePair.Key).ShouldBeTrue();
                tree.Search(keyValuePair.Key).ShouldBe(keyValuePair.Value);

                tree.TrySearch(keyValuePair.Key, out value).ShouldBeTrue();
                value.ShouldBe(keyValuePair.Value);
            }

            for (Int32 number = -1000; number < 1000; number++)
            {
                tree.Remove(number).ShouldBe(this.values.Select(keyValuePair => keyValuePair.Key).Contains(number));
            }

            tree.Count.ShouldBe(0);

            foreach (KeyValuePair <Int32, String> keyValuePair in this.values)
            {
                tree.Insert(keyValuePair.Key, keyValuePair.Value);
            }

            tree.Clear();

            tree.Count.ShouldBe(0);

            foreach (KeyValuePair <Int32, String> keyValuePair in this.values)
            {
                tree.Contains(keyValuePair.Key).ShouldBeFalse();
                tree.TrySearch(keyValuePair.Key, out value).ShouldBeFalse();
            }

            // exceptions

            Should.Throw <ArgumentException>(() => tree.Search(0));
            Should.Throw <ArgumentException>(() =>
            {
                tree.Insert(0, String.Empty);
                tree.Insert(0, String.Empty);
            });

            AvlTree <Object, String> objectTree = new AvlTree <Object, String>();

            Should.Throw <ArgumentNullException>(() => objectTree.Insert(null, null));
            Should.Throw <ArgumentNullException>(() => objectTree.Contains(null));
            Should.Throw <ArgumentNullException>(() => objectTree.TrySearch(null, out value));
            Should.Throw <ArgumentNullException>(() => objectTree.Remove(null));
        }
Exemple #6
0
        public void ClearPUT([PexAssumeUnderTest] List <int> values)
        {
            AvlTree <int> actual = new AvlTree <int>(values);

            PexAssert.AreEqual(values.Count, actual.Count);
            actual.Clear();
            PexAssert.AreEqual(0, actual.Count);
        }
Exemple #7
0
        public void ClearTest()
        {
            AvlTree <int> actual = new AvlTree <int> {
                1, 3, 5, 6, 9, 7
            };

            Assert.AreEqual(6, actual.Count);
            actual.Clear();
            Assert.AreEqual(0, actual.Count);
        }
Exemple #8
0
        private void LoadLevel(int level)
        {
            if (this.relationLevelLoaded[level])
            {
                return;
            }

            CurrencyManager       cm    = this.relationBindings[level];
            AvlTree <RadTreeNode> nodes = this.relationIndex[level];

            nodes.Clear();

            for (int j = 0; j < cm.Count; j++)
            {
                RadTreeNode node = this.TreeView.CreateNewNode();
                ((IDataItem)node).DataBoundItem = cm.List[j];
                node.BoundIndex = level + 1;
                nodes.Add(node);
            }

            this.relationLevelLoaded[level] = true;
        }
Exemple #9
0
 public void Clear()
 {
     posTree.Clear();
     fTree.Clear();
     size = 0;
 }