コード例 #1
0
ファイル: Set.cs プロジェクト: csfmeridian/jabber-net
 /// <summary>
 /// Creates a set with the given back-end implementation.
 /// </summary>
 /// <param name="impl">How to implement the set.</param>
 public Set(SetImplementation impl)
 {
     switch (impl)
     {
         case SetImplementation.Hashtable:
             m_dict = new Hashtable();
             break;
         case SetImplementation.Tree:
             m_dict = new Tree();
             break;
         case SetImplementation.SkipList:
             m_dict = new SkipList();
             break;
         default:
             throw new NotImplementedException("Unknown SetImplementation");
     }
 }
コード例 #2
0
ファイル: SetTest.cs プロジェクト: JustOxlamon/TwoRatChat
        private void all(SetImplementation i)
        {
            Set s = new Set(i);

            Assert.AreEqual(0, s.Count);

            s.Add("one");
            Assert.AreEqual(1, s.Count);
            Assert.IsTrue(s.Contains("one"));
            Assert.IsTrue(!s.Contains("two"));
            Assert.IsTrue(!s.Contains("three"));

            s.Add("two");
            Assert.AreEqual(2, s.Count);
            Assert.IsTrue(s.Contains("one"));
            Assert.IsTrue(s.Contains("two"));
            Assert.IsTrue(!s.Contains("three"));

            s.Remove("one");
            Assert.AreEqual(1, s.Count);
            Assert.IsTrue(!s.Contains("one"));
            Assert.IsTrue(s.Contains("two"));
            Assert.IsTrue(!s.Contains("three"));

            s.Add("one");
            Assert.AreEqual(2, s.Count);
            Assert.IsTrue(s.Contains("one"));
            Assert.IsTrue(s.Contains("two"));
            Assert.IsTrue(!s.Contains("three"));

            s.Add("one");
            Assert.AreEqual(2, s.Count);
            Assert.IsTrue(s.Contains("one"));
            Assert.IsTrue(s.Contains("two"));
            Assert.IsTrue(!s.Contains("three"));

            int count = 0;

            foreach (string str in s)
            {
                count++;
                Assert.AreEqual(3, str.Length);
            }
            Assert.AreEqual(2, count);
        }
コード例 #3
0
ファイル: SetTest.cs プロジェクト: krbysn/jabber-net
        private void all(SetImplementation i)
        {
            Set s = new Set(i);
            Assert.AreEqual(0, s.Count);

            s.Add("one");
            Assert.AreEqual(1, s.Count);
            Assert.IsTrue(s.Contains("one"));
            Assert.IsTrue(!s.Contains("two"));
            Assert.IsTrue(!s.Contains("three"));

            s.Add("two");
            Assert.AreEqual(2, s.Count);
            Assert.IsTrue(s.Contains("one"));
            Assert.IsTrue(s.Contains("two"));
            Assert.IsTrue(!s.Contains("three"));

            s.Remove("one");
            Assert.AreEqual(1, s.Count);
            Assert.IsTrue(!s.Contains("one"));
            Assert.IsTrue(s.Contains("two"));
            Assert.IsTrue(!s.Contains("three"));

            s.Add("one");
            Assert.AreEqual(2, s.Count);
            Assert.IsTrue(s.Contains("one"));
            Assert.IsTrue(s.Contains("two"));
            Assert.IsTrue(!s.Contains("three"));

            s.Add("one");
            Assert.AreEqual(2, s.Count);
            Assert.IsTrue(s.Contains("one"));
            Assert.IsTrue(s.Contains("two"));
            Assert.IsTrue(!s.Contains("three"));

            int count = 0;
            foreach (string str in s)
            {
                count++;
                Assert.AreEqual(3, str.Length);
            }
            Assert.AreEqual(2, count);
        }
コード例 #4
0
        /// <summary>
        /// Creates a set with the given back-end implementation.
        /// </summary>
        /// <param name="impl">How to implement the set.</param>
        public Set(SetImplementation impl)
        {
            switch (impl)
            {
            case SetImplementation.Hashtable:
                m_dict = new Hashtable();
                break;

            case SetImplementation.Tree:
                m_dict = new Tree();
                break;

            case SetImplementation.SkipList:
                m_dict = new SkipList();
                break;

            default:
                throw new NotImplementedException("Unknown SetImplementation");
            }
        }