Exemplo n.º 1
0
        public void IteratorTest()
        {
            var set = UnsafeDictionary.Allocate <int, decimal>(10);

            // Fill set
            for (int i = 0; i < 10; i++)
            {
                // Add in reverse order
                UnsafeDictionary.Add <int, decimal>(set, i, i * i);
            }

            var enumerator = UnsafeDictionary.GetEnumerator <int, decimal>(set);

            for (int i = 0; i < 10; i++)
            {
                enumerator.MoveNext();
                Assert.AreEqual(i, enumerator.CurrentKey);
                Assert.AreEqual(i * i, enumerator.CurrentValue);

                Assert.AreEqual(i, enumerator.Current.Key);
                Assert.AreEqual(i * i, enumerator.Current.Value);
            }

            UnsafeDictionary.Free(set);
        }