Exemplo n.º 1
0
        public void GenericNumberListColumn_Basics()
        {
            List <int> empty = new List <int>();

            GenericNumberListColumn <int> column = new GenericNumberListColumn <int>();

            column[0] = new int[] { 0, 1, 2 };

            TreeDiagnostics diagnostics      = TreeSerializer.Diagnostics(column, TreeFormat.Binary);
            int             tinyColumnLength = (int)diagnostics.Length;

            Column.Basics(() => new GenericNumberListColumn <int>(), null, column[0], (index) =>
            {
                IList <int> values = column[index];
                if (values == null || values.Count == 0)
                {
                    column[index] = new int[] { index, index + 1, index + 2 };
                    values        = column[index];
                }

                return(values);
            });

            // ForEach
            column.Clear();
            column[0] = new int[] { 0, 1, 2 };
            int sum = 0;

            column.ForEach((slice) =>
            {
                int[] array = slice.Array;
                int end     = slice.Index + slice.Count;
                for (int i = slice.Index; i < end; ++i)
                {
                    sum += array[i];
                }
            });
            Assert.Equal(3, sum);
        }