Exemple #1
0
 private void ClearAllStructures()
 {
     StructureTable.Rows.Clear();
     NameGenreTable.Rows.Clear();
     NameAuthorTable.Rows.Clear();
     NameGenreHT.Clear();
     NameAuthorHT.Clear();
     YearTree.Clear();
     PublisherTree.Clear();
     NameTree.Clear();
     structureForm.Name_comboBox.Items.Clear();
 }
Exemple #2
0
        public void Clear_TrueTest()
        {
            IRBTree <int, string> target = new RBTree <int, string>();

            target.Add(1, "1");
            target.Add(5, "5");
            target.Add(2, "2");
            target.Add(12, "12");
            target.Add(4, "4");

            target.Clear();

            Assert.AreEqual(0, target.Count);
            Assert.IsFalse(target.ContainsKey(1));

            target.Add(1, "1");
            Assert.AreEqual(1, target.Count);
            Assert.IsTrue(target.ContainsKey(1));
        }
Exemple #3
0
 public void Clear()
 {
     array.Clear();
 }
Exemple #4
0
        public void SimpleTreeTest()
        {
            //Console.WriteLine("rbtree");

            Random       r = new Random((int)(DateTime.Now.Ticks ^ 0xffff));
            RBTree <int> tree = new RBTree <int>();
            List <int>   vals = new List <int>();
            List <int>   removed = new List <int>();
            int          i, j, k;

            //fill tree
            while (tree.Count != 1000)
            {
                i = r.Next(10000);
                if (tree.Find(i) != null)
                {
                    continue;
                }
                tree.Add(i);
                vals.Add(i);
            }

            //check presence of the values
            k = 0;
            foreach (int val in vals)
            {
                if (tree.Find(val) == null)
                {
                    k++;
                }
            }

            Assert.AreEqual(k, 0);
            //Console.WriteLine("{0}", k == 0 ? "ok" : "failed");


            //check order
            j = -1;
            foreach (RBTreeNode <int> node in tree)
            {
                if (node.Key < j)
                {
                    k++;
                }
            }
            Assert.AreEqual(k, 0);
            //Console.WriteLine("{0}", k == 0 ? "ok" : "failed");

            //check remove
            for (i = 0; i < vals.Count; i += 25)
            {
                tree.Remove(vals[i]);
                removed.Add(vals[i]);
                vals.RemoveAt(i);
            }

            k = 0;
            foreach (int val in vals)
            {
                if (tree.Find(val) == null)
                {
                    k++;
                }
            }
            foreach (int val in removed)
            {
                if (tree.Find(val) != null)
                {
                    k++;
                }
            }
            Assert.AreEqual(k, 0);
            //Console.WriteLine("{0}", k == 0 ? "ok" : "failed");

            //chaos test
            k = 0;
            for (j = 0; j < 50; j++)
            {
                tree.Clear();
                vals.Clear();
                removed.Clear();

                //fill tree
                while (tree.Count != 5000)
                {
                    i = r.Next(100000);
                    if (tree.Find(i) != null)
                    {
                        continue;
                    }
                    tree.Add(i);
                    vals.Add(i);
                }

                while (tree.Count != 100)
                {
                    i = r.Next(vals.Count);
                    tree.Remove(vals[i]);

                    removed.Add(vals[i]);
                    vals.RemoveAt(i);
                }

                foreach (int val in vals)
                {
                    if (tree.Find(val) == null)
                    {
                        k++;
                    }
                }
                foreach (int val in removed)
                {
                    if (tree.Find(val) != null)
                    {
                        k++;
                    }
                }
            }
            Assert.AreEqual(k, 0);
            //Console.WriteLine("{0}", k == 0 ? "ok" : "failed");
        }