Пример #1
0
        public void Add()
        {
            MultiKeyDistinctValueDictionary <string, string> dictionary = new MultiKeyDistinctValueDictionary <string, string>();

            dictionary.Add("1", "2");
            Assert.AreEqual(1, dictionary.Count);
            Assert.IsTrue(dictionary.ContainsKey("1"));
            Assert.IsTrue(dictionary.Contains("1", "2"));
            Assert.AreEqual("2", dictionary["1"].First());

            dictionary.Add("1", "2");
            Assert.AreEqual(1, dictionary.Count);

            dictionary.Add("1", "3");
            Assert.AreEqual(2, dictionary.Count);
            Assert.IsTrue(dictionary.ContainsKey("1"));
            Assert.IsTrue(dictionary.Contains("1", "2"));
            Assert.IsTrue(dictionary.Contains("1", "3"));

            dictionary.Add("2", "1");
            Assert.AreEqual(3, dictionary.Count);
            Assert.IsTrue(dictionary.ContainsKey("1"));
            Assert.IsTrue(dictionary.ContainsKey("2"));
            Assert.IsTrue(dictionary.Contains("1", "2"));
            Assert.IsTrue(dictionary.Contains("1", "3"));
            Assert.IsTrue(dictionary.Contains("2", "1"));
        }
Пример #2
0
        public void Add_Sequence()
        {
            MultiKeyDistinctValueDictionary <string, string> dictionary = new MultiKeyDistinctValueDictionary <string, string>();

            dictionary.Add("1", new List <string>()
            {
                "2", "3"
            });
            Assert.AreEqual(2, dictionary.Count);
            Assert.IsTrue(dictionary.ContainsKey("1"));
            Assert.IsTrue(dictionary.Contains("1", "2"));
            Assert.IsTrue(dictionary.Contains("1", "3"));
        }
Пример #3
0
 private void InitializeMorphemes(IEnumerable <Morpheme> morphemes)
 {
     using (Trace.Entering())
     {
         MorphemeEqualityComparer morphemeEqualityComparer = new MorphemeEqualityComparer();
         myLexemes    = new MultiKeyDistinctValueDictionary <string, Morpheme>(EqualityComparer <string> .Default, morphemeEqualityComparer);
         myNonLexemes = new MultiKeyDistinctValueDictionary <string, Morpheme>(EqualityComparer <string> .Default, morphemeEqualityComparer);
         foreach (Morpheme morpheme in morphemes)
         {
             if (morpheme.IsLexeme)
             {
                 myLexemes.Add(morpheme.Morph, morpheme);
             }
             else
             {
                 myNonLexemes.Add(morpheme.Morph, morpheme);
             }
         }
     }
 }