Ejemplo n.º 1
0
        public ICollection <AggregationResultItem <T> > Flatten(FlattenMode mode = FlattenMode.SubLevelFirst)
        {
            List <AggregationResultItem <T> > list = new List <AggregationResultItem <T> >();

            if (mode == FlattenMode.SubLevelFirst || mode == FlattenMode.TopLevelFirst)
            {
                Flatten(Items, list, mode);
            }
            else
            {
                IEnumerable <AggregationResultItem <T>[]> generations = _generations;

                if (mode == FlattenMode.LaterGenerationFirst)
                {
                    generations = generations.Reverse();
                }

                foreach (var gen in generations)
                {
                    list.AddRange(gen);
                }
            }

            return(list.AsReadOnly());
        }
Ejemplo n.º 2
0
 public static Matrix <T> Flatten <T>(Matrix <T> matrix, int dimensionFrom, int dimensionTo, FlattenMode mode = Operators.Flatten <T> .DefaultMode)
 {
     return(matrix.Flatten(dimensionFrom, dimensionTo, mode));
 }
Ejemplo n.º 3
0
        private static void Flatten(IEnumerable <AggregationResultItem <T> > items, List <AggregationResultItem <T> > list, FlattenMode mode)
        {
            foreach (var item in items)
            {
                if (mode == FlattenMode.TopLevelFirst)
                {
                    list.Add(item);
                }

                Flatten(item.SubItems, list, mode);

                if (mode == FlattenMode.SubLevelFirst)
                {
                    list.Add(item);
                }
            }
        }
Ejemplo n.º 4
0
 public Flatten(int dimensionFrom, int dimensionTo, FlattenMode mode = DefaultMode)
 {
     DimensionFrom = dimensionFrom;
     DimensionTo   = dimensionTo;
     Mode          = mode;
 }
Ejemplo n.º 5
0
 /// <see cref="Operators.Flatten{T}"/>
 public static Matrix <T> Flatten <T>(this Matrix <T> matrix, int dimensionFrom, int dimensionTo, FlattenMode mode = FlattenMode.Extend)
 {
     return(new Flatten <T>(dimensionFrom, dimensionTo, mode)
     {
         Param = matrix
     });
 }