public void FastLookupDictionaryTryGetValueShouldContainAllValuesOfLargeList()
 {
     var fastLookupDictionary = new FastLookupDictionary<int, int>();
     for (int i = 0; i < 50; i++)
     {
         fastLookupDictionary.Add(i, i);
         int value;
         Assert.IsTrue(fastLookupDictionary.TryGetValue(i, out value));
     }
 }
 public void FastLookupDictionaryGetValueShouldContainAllValuesOfSmallList()
 {
     var fastLookupDictionary = new FastLookupDictionary<int, int>();
     for (int i = 0; i < 2; i++)
     {
         fastLookupDictionary.Add(i, i);
         var value = fastLookupDictionary[i];
         Assert.AreEqual(i, value);
     }
 }
示例#3
0
        public void FastLookupDictionaryTryGetValueShouldContainAllValuesOfLargeList()
        {
            var fastLookupDictionary = new FastLookupDictionary <int, int>();

            for (int i = 0; i < 50; i++)
            {
                fastLookupDictionary.Add(i, i);
                Assert.IsTrue(fastLookupDictionary.TryGetValue(i, out _));
            }
        }
        public void FastLookupDictionaryGetValueShouldContainAllValuesOfSmallList()
        {
            var fastLookupDictionary = new FastLookupDictionary <int, int>();

            for (int i = 0; i < 2; i++)
            {
                fastLookupDictionary.Add(i, i);
                var value = fastLookupDictionary[i];
                Assert.AreEqual(i, value);
            }
        }
        public void FastLookupDictionaryTryGetValueShouldReturnValueWithSameHashCode()
        {
            // create two elements with the same hashcode
            var first = new Element(1);
            var second = new Element(1);

            var fastLookupDictionary = new FastLookupDictionary<Element, Element>();
            fastLookupDictionary[first] = second;

            Element third = null;
            Assert.IsTrue(fastLookupDictionary.TryGetValue(second, out third));
            Assert.IsTrue(ReferenceEquals(third, second));
        }
示例#6
0
        public void FastLookupDictionaryTryGetValueShouldReturnValueWithSameHashCode()
        {
            // create two elements with the same hashcode
            var first  = new Element(1);
            var second = new Element(1);

            var fastLookupDictionary = new FastLookupDictionary <Element, Element>
            {
                [first] = second
            };

            Assert.IsTrue(fastLookupDictionary.TryGetValue(second, out Element third));
            Assert.IsTrue(ReferenceEquals(third, second));
        }
示例#7
0
 public LexemeFactoryRegistry()
 {
     _registry = new FastLookupDictionary<LexerRuleType, ILexemeFactory>();
 }