Exemple #1
0
        public void IteratorTest()
        {
            var set = UnsafeSortedDictionary.Allocate <int, decimal>(10);

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

            var enumerator = UnsafeSortedDictionary.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);
            }

            UnsafeSortedDictionary.Free(set);
        }