Contains() public method

Returns true if this FrequencyDictionary contains the specified word. More formally, returns true if and only if this FrequencyDictionary contains at least one word.
public Contains ( List str ) : bool
str List /// word is built from letters /// whose presence in this FrequencyDictionary is to be tested ///
return bool
コード例 #1
0
 public void AddTest()
 {
     var alphabet = new FrequencyDictionary();
     var alphabetTest = new FrequencyDictionary(chain);
     string[] words = { "A", "G", "C", "T" };
     int power = 1;
     alphabet.Add(words[0], alphabetTest[words[0]]);
     alphabet.Add(words[0], alphabetTest[words[0]]);
     Assert.True(alphabet.Contains(words[0]) && alphabet.Count == power);
 }
コード例 #2
0
 public void ContainsTest()
 {
     var alphabet = new FrequencyDictionary(chain);
     string[] words = { "A", "G", "C", "T", "WORD", "AG" };
     Assert.True(alphabet.Contains(words[0]));
     Assert.True(alphabet.Contains(words[1]));
     Assert.True(alphabet.Contains(words[2]));
     Assert.True(alphabet.Contains(words[3]));
     Assert.True(!alphabet.Contains(words[4]));
     Assert.True(!alphabet.Contains(words[5]));
 }
コード例 #3
0
        /// <summary>
        /// Discards all words which enter in the alphabet and contains compound words
        /// </summary>
        /// <param name="alphabet">
        /// The alphabet.
        /// </param>
        /// <param name="level">
        /// The filter level.
        /// </param>
        /// <returns>
        /// The <see cref="T:KeyValuePair{List{string},List{int}}?"/>.
        /// </returns>
        protected KeyValuePair<List<string>, List<int>>? DiscardCompositeWords(FrequencyDictionary alphabet, double level)
        {
            var stds = new List<double>(wordPriority.Keys);
            var entries = new List<KeyValuePair<List<string>, List<int>>>(wordPriority.Values);
            for (int index = entries.Count; --index >= 0;)
            {
                List<string> entry = entries[index].Key;
                string entryS;
                if (!alphabet.Contains(new ValueString(entryS = Helper.ToString(entry))) && (entry.Count == entryS.Length))
                {
                    double bestStd = stds[index];
                    if (bestStd > level)
                    {
                        return new KeyValuePair<List<string>, List<int>>(wordPriority[bestStd].Key, wordPriority[bestStd].Value);
                    }
                }
            }

            return null;
        }
コード例 #4
0
 public void RemoveTest()
 {
     var alphabet = new FrequencyDictionary(chain);
     string[] words = { "A", "G", "C", "T", "WORD", "AG" };
     alphabet.Remove(words[0]);
     Assert.True(!alphabet.Contains(words[0]));
     alphabet.Remove(words[1]);
     Assert.True(!alphabet.Contains(words[1]));
     alphabet.Remove(words[2]);
     Assert.True(!alphabet.Contains(words[2]));
     alphabet.Remove(words[3]);
     Assert.True(!alphabet.Contains(words[3]));
     Assert.True(alphabet.Count == 0);
 }
コード例 #5
0
        public void PutTest()
        {
            var alphabet = new FrequencyDictionary(chain);
            string word = "string";
            string unknown = "WOW";
            int pos = 20;
            alphabet.Put(word, pos);

            Assert.True(alphabet.Contains(word));
            Assert.True(!alphabet.Contains(unknown));
        }
コード例 #6
0
 public void GetWordTest()
 {
     var alphabet = new FrequencyDictionary(chain);
     for (int index = 0; index < alphabet.Count; index++)
     {
         Assert.True(alphabet.Contains(alphabet.GetWord(index)));
     }
 }
コード例 #7
0
        /// <summary>
        /// The equals.
        /// </summary>
        /// <param name="other">
        /// The other frequency dictionary.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Equals(FrequencyDictionary other)
        {
            if (other.Count != words.Count)
            {
                return false;
            }

            for (int index = 0; index < Count; index++)
            {
                if (!other.Contains(GetWord(index)))
                {
                    return false;
                }
            }

            return true;
        }