コード例 #1
0
        public void TransformToZero()
        {
            CompressingTreeList <int> list = new CompressingTreeList <int>((a, b) => a == b);

            list.AddRange(new[] { 0, 1, 1, 0 });
            list.Transform(i => 0);
            Assert.AreEqual(new[] { 0, 0, 0, 0 }, list.ToArray());
        }
コード例 #2
0
        public void Transform()
        {
            CompressingTreeList <int> list = new CompressingTreeList <int>((a, b) => a == b);

            list.AddRange(new[] { 0, 1, 1, 0 });
            int calls = 0;

            list.Transform(i => { calls++; return(i + 1); });
            Assert.AreEqual(3, calls);
            Assert.AreEqual(new[] { 1, 2, 2, 1 }, list.ToArray());
        }