Ejemplo n.º 1
0
 [Test] public void Test_Add()
 {
     SkipList sl = new SkipList();
     Assert.AreEqual(0, sl.Count);
     sl.Add("1", "bar");
     Assert.AreEqual(1, sl.Count);
     sl.Add("2", "baz");
     Assert.AreEqual(2, sl.Count);
 }
Ejemplo n.º 2
0
 public void Test_Clear()
 {
     SkipList sl = new SkipList();
     for (int i=0; i<4096; i++)
     {
         sl[i] = i.ToString();
     }
     Assert.AreEqual(4096, sl.Count);
     sl.Clear();
     Assert.AreEqual(0, sl.Count);
 }
Ejemplo n.º 3
0
 [Test] public void Test_Lots_InOrder()
 {
     SkipList sl = new SkipList();
     for (int i=0; i<4096; i++)
     {
         sl[i] = i.ToString();
     }
     Assert.AreEqual(4096, sl.Count);
     for (int i=0; i<4096; i++)
     {
         Assert.AreEqual(i.ToString(), sl[i]);
     }
 }
Ejemplo n.º 4
0
 public void Test_DictIteration()
 {
     SkipList sl = new SkipList();
     for (int i=0; i<4096; i++)
     {
         sl[i] = i.ToString();
     }
     Assert.AreEqual(4096, sl.Count);
     int count = 0;
     IDictionaryEnumerator e = sl.GetEnumerator();
     while (e.MoveNext())
     {
         Assert.AreEqual(count, e.Key);
         Assert.AreEqual(count.ToString(), e.Value);
         count++;
     }
     Assert.AreEqual(4096, count);
 }
Ejemplo n.º 5
0
        [Test] public void Test_Lots_Random()
        {
            SkipList sl = new SkipList();
            Random r = new Random();
            int[] nums = new int[4096];

            for (int i=0; i<4096; i++)
            {
                nums[i] = r.Next(10000);
                while (sl.Contains(nums[i]))
                {
                    nums[i] = r.Next(10000);
                }
                sl[nums[i]] = i.ToString();
            }
            Assert.AreEqual(4096, sl.Count);
            for (int i=0; i<4096; i++)
            {
                Assert.AreEqual(i.ToString(), sl[nums[i]]);
            }
        }
Ejemplo n.º 6
0
 public SkipListEnumerator(SkipList list)
 {
     m_list = list;
     m_node = m_list.m_header;
 }
Ejemplo n.º 7
0
 [Test] public void Test_Iteration()
 {
     SkipList sl = new SkipList();
     for (int i=0; i<4096; i++)
     {
         sl[i] = i.ToString();
     }
     Assert.AreEqual(4096, sl.Count);
     int count = 0;
     foreach (DictionaryEntry de in sl)
     {
         Assert.AreEqual(count, de.Key);
         Assert.AreEqual(count.ToString(), de.Value);
         count++;
     }
     Assert.AreEqual(4096, count);
 }
Ejemplo n.º 8
0
 [Test] public void Test_Get()
 {
     SkipList sl = new SkipList();
     sl.Add("1", "bar");
     Assert.AreEqual("bar", sl["1"]);
 }
Ejemplo n.º 9
0
 [Test] public void Test_Key_Twice()
 {
     SkipList sl = new SkipList();
     sl.Add("one", "one");
     sl.Add("one", "one");
 }
Ejemplo n.º 10
0
 [Test] public void Test_Null_Key()
 {
     SkipList sl = new SkipList();
     sl.Add(null, "one");
 }
Ejemplo n.º 11
0
 [Test] public void Test_Remove()
 {
     SkipList sl = new SkipList();
     sl[0] = 0;
     Assert.AreEqual(1, sl.Count);
     sl.Remove(0);
     Assert.AreEqual(0, sl.Count);
 }
Ejemplo n.º 12
0
 public SkipListEnumerator(SkipList list)
 {
     m_list = list;
     m_node = m_list.m_header;
 }