Example #1
0
        public void ImmutableHashTree_Conflict_GetValue()
        {
            var tree = ImmutableHashTree <ConflictClass, int> .Empty;

            for (var i = 0; i < 1000; i++)
            {
                tree = tree.Add(new ConflictClass(i % 5, i), i);
            }

            Assert.Equal(1000, tree.Count);

            for (var i = 0; i < 1000; i++)
            {
                var conflict = new ConflictClass(i % 5, i);

                Assert.Equal(i, tree.GetValueOrDefault(conflict));
            }
        }
Example #2
0
        public void ImmutableHashTree_Conflict_Index()
        {
            var tree = ImmutableHashTree <ConflictClass, int> .Empty;

            for (var i = 0; i < 1000; i++)
            {
                tree = tree.Add(new ConflictClass(i % 5, i), i);
            }

            Assert.Equal(1000, tree.Count);

            for (var i = 0; i < 1000; i++)
            {
                var conflict = new ConflictClass(i % 5, i);

                Assert.Equal(i, tree[conflict]);
            }
        }