Example #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);
 }
Example #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);
 }
Example #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]);
     }
 }
Example #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);
 }
Example #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]]);
            }
        }
Example #6
0
 public SkipListEnumerator(SkipList list)
 {
     m_list = list;
     m_node = m_list.m_header;
 }
Example #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);
 }
Example #8
0
 [Test] public void Test_Get()
 {
     SkipList sl = new SkipList();
     sl.Add("1", "bar");
     Assert.AreEqual("bar", sl["1"]);
 }
Example #9
0
 [Test] public void Test_Key_Twice()
 {
     SkipList sl = new SkipList();
     sl.Add("one", "one");
     sl.Add("one", "one");
 }
Example #10
0
 [Test] public void Test_Null_Key()
 {
     SkipList sl = new SkipList();
     sl.Add(null, "one");
 }
Example #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);
 }
Example #12
0
 public SkipListEnumerator(SkipList list)
 {
     m_list = list;
     m_node = m_list.m_header;
 }