예제 #1
0
파일: HashTable.cs 프로젝트: vosen/kora
 public void Delete()
 {
     uint size = 128;
     string temp = null;
     var table = new HashTable<string>();
     for (uint i = 0; i < size; i++)
     {
         table.Add(i, i.ToString());
         CheckInnerTables(table);
     }
     for (uint i = 0; i < size; i++)
     {
         Assert.IsTrue(table.TryGetValue(i, out temp));
         Assert.AreEqual(i.ToString(), temp);
     }
     for (uint i = 0; i < size; i++)
     {
         table.Remove(i);
         CheckInnerTables(table);
     }
     for (uint i = 0; i < size; i++)
     {
         Assert.IsFalse(table.TryGetValue(i, out temp));
     }
 }
예제 #2
0
파일: HashTable.cs 프로젝트: tchen0123/kora
        public void Adding()
        {
            var table = new HashTable <string>();

            table.Add(1, "1");
            CheckInnerTables(table);
            table.Add(2, "2");
            CheckInnerTables(table);
            table.Add(3, "3");
            CheckInnerTables(table);
            table.Add(4, "4");
            CheckInnerTables(table);
            table.Add(5, "5");
            CheckInnerTables(table);
            table.Add(6, "6");
            CheckInnerTables(table);
            table.Add(7, "7");
            CheckInnerTables(table);
            table.Add(8, "8");
            CheckInnerTables(table);
            string temp = null;

            Assert.IsTrue(table.TryGetValue(1, out temp));
            Assert.AreEqual("1", temp);
            Assert.IsTrue(table.TryGetValue(2, out temp));
            Assert.AreEqual("2", temp);
            Assert.IsTrue(table.TryGetValue(3, out temp));
            Assert.AreEqual("3", temp);
            Assert.IsTrue(table.TryGetValue(4, out temp));
            Assert.AreEqual("4", temp);
            Assert.IsTrue(table.TryGetValue(5, out temp));
            Assert.AreEqual("5", temp);
            Assert.IsTrue(table.TryGetValue(6, out temp));
            Assert.AreEqual("6", temp);
            Assert.IsTrue(table.TryGetValue(7, out temp));
            Assert.AreEqual("7", temp);
            Assert.IsTrue(table.TryGetValue(8, out temp));
            Assert.AreEqual("8", temp);
        }
예제 #3
0
파일: HashTable.cs 프로젝트: vosen/kora
 public void Adding()
 {
     var table = new HashTable<string>();
     table.Add(1, "1");
     CheckInnerTables(table);
     table.Add(2, "2");
     CheckInnerTables(table);
     table.Add(3, "3");
     CheckInnerTables(table);
     table.Add(4, "4");
     CheckInnerTables(table);
     table.Add(5, "5");
     CheckInnerTables(table);
     table.Add(6, "6");
     CheckInnerTables(table);
     table.Add(7, "7");
     CheckInnerTables(table);
     table.Add(8, "8");
     CheckInnerTables(table);
     string temp = null;
     Assert.IsTrue(table.TryGetValue(1, out temp));
     Assert.AreEqual("1", temp);
     Assert.IsTrue(table.TryGetValue(2, out temp));
     Assert.AreEqual("2", temp);
     Assert.IsTrue(table.TryGetValue(3, out temp));
     Assert.AreEqual("3", temp);
     Assert.IsTrue(table.TryGetValue(4, out temp));
     Assert.AreEqual("4", temp);
     Assert.IsTrue(table.TryGetValue(5, out temp));
     Assert.AreEqual("5", temp);
     Assert.IsTrue(table.TryGetValue(6, out temp));
     Assert.AreEqual("6", temp);
     Assert.IsTrue(table.TryGetValue(7, out temp));
     Assert.AreEqual("7", temp);
     Assert.IsTrue(table.TryGetValue(8, out temp));
     Assert.AreEqual("8", temp);
 }
예제 #4
0
파일: HashTable.cs 프로젝트: tchen0123/kora
        public void Creation()
        {
            var table = new HashTable <string>();

            CheckInnerTables(table);
        }
예제 #5
0
파일: HashTable.cs 프로젝트: vosen/kora
 private static void CheckInnerTables(HashTable<string> table)
 {
     foreach (var inner in table.inner)
     {
         foreach (var pair in inner.table)
         {
             if (pair != null)
                 Assert.AreNotEqual(null, pair.Value);
         }
     }
 }
예제 #6
0
파일: HashTable.cs 프로젝트: vosen/kora
 public void MultipleSameAdd()
 {
     var table = new HashTable<string>();
     table.Add(0, "0");
     for (int i = 0; i < 7; i++)
         Assert.Throws<ArgumentException>(() => table.Add(0, "0"));
     Assert.AreEqual(1, table.Count);
 }
예제 #7
0
파일: HashTable.cs 프로젝트: vosen/kora
 public void Creation()
 {
     var table = new HashTable<string>();
     CheckInnerTables(table);
 }
예제 #8
0
파일: HashTable.cs 프로젝트: vosen/kora
 public void AddWithCollision()
 {
     var table = new HashTable<string>();
     table.Add(1, "1");
     CheckInnerTables(table);
     uint firstHash = table.GetHash(1);
     uint collision = 2;
     while(!(table.GetHash(collision) == firstHash))
     {
         collision++;
     }
     // HACK WARNING: I create collision instead of generating it
     uint secondHash = table.inner[firstHash].GetHash(collision);
     table.inner[firstHash].a = 0;
     table.inner[firstHash].b = secondHash;
     table.Add(collision, collision.ToString());
     CheckInnerTables(table);
     string temp = null;
     Assert.IsTrue(table.TryGetValue(collision, out temp));
     Assert.AreEqual(collision.ToString(), temp);
 }