Visual Computing Library
Loading...
Searching...
No Matches
vcl::NestedInitializerListsProcessor< T, L > Class Template Reference

The NestedInitializerListsProcessor class. More...

#include <vclib/misc/nested_initializer_lists.h>

Static Public Member Functions

static std::list< size_tmaxDimensionsLevels (NestedInitializerLists< T, L > values)
 Returns a list containing the maximum size of elements for every dimension.
 
template<typename T_Function >
static void processElements (NestedInitializerLists< T, L > values, T_Function function)
 Applies the lambda function passed as parameter to all the elements of the NestedInitializerLists.
 
template<typename T_Function >
static void processElements (NestedInitializerLists< T, L > values, T_Function function, std::list< size_t > sizes)
 Applies the lambda function passed as parameter to all the elements of the NestedInitializerLists.
 

Detailed Description

template<typename T, std::size_t L>
class vcl::NestedInitializerListsProcessor< T, L >

The NestedInitializerListsProcessor class.

Proposes some helper static functions that allows to process vcl::NestedInitializerLists of L levels.

Member Function Documentation

◆ maxDimensionsLevels()

template<typename T , std::size_t L>
static std::list< size_t > vcl::NestedInitializerListsProcessor< T, L >::maxDimensionsLevels ( NestedInitializerLists< T, L >  values)
inlinestatic

Returns a list containing the maximum size of elements for every dimension.

{{2, 3, 5, 4}, {2}, {2, 4, 6}});
//the list will contain the values 3 and 4.
{
{{2, 3}, {5, 4}, {6}, {2, 5}},
{{2}, {3, 4, 6}}
} );
//the list will contain the values 2, 4 and 3.
static std::list< size_t > maxDimensionsLevels(NestedInitializerLists< T, L > values)
Returns a list containing the maximum size of elements for every dimension.
Definition nested_initializer_lists.h:103
Parameters
[in]valuesthe nested initializer lists
Returns
a list of L numbers, where every number is the maximum size of elements for every dimension.

◆ processElements() [1/2]

template<typename T , std::size_t L>
template<typename T_Function >
static void vcl::NestedInitializerListsProcessor< T, L >::processElements ( NestedInitializerLists< T, L >  values,
T_Function  function 
)
inlinestatic

Applies the lambda function passed as parameter to all the elements of the NestedInitializerLists.

Example: save all the elements in a vector:

std::vector<T> v;
// resize vector proprerly, see
// NestedInitializerListsProcessor<T, N>::maxDimensionsLevel
typename std::vector<T>::iterator iterator = v.begin();
[&iterator](T value) { *(iterator++) = value; });
static void processElements(NestedInitializerLists< T, L > values, T_Function function)
Applies the lambda function passed as parameter to all the elements of the NestedInitializerLists.
Definition nested_initializer_lists.h:155
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
Note
This function does not take into account the sizes of every list. If some values are missing from the lists they will be skipped and function is not applied.
Parameters
values
functiona lambda function that takes an argument of type T as input.

◆ processElements() [2/2]

template<typename T , std::size_t L>
template<typename T_Function >
static void vcl::NestedInitializerListsProcessor< T, L >::processElements ( NestedInitializerLists< T, L >  values,
T_Function  function,
std::list< size_t sizes 
)
inlinestatic

Applies the lambda function passed as parameter to all the elements of the NestedInitializerLists.

Example: save all the elements in a vector:

std::vector<T> v;
// resize vector proprerly, see
//NestedInitializerListsProcessor<T,N>::maxDimensionsLevel
std::list<std::size_t> sizes;
// push values properly in sizes (example:
// sizes = NestedInitializerListsProcessor<T, N>::maxDimensionsLevel)
typename std::vector<T>::iterator iterator = v.begin();
[&iterator](T value) { *(iterator++) = value; });
Note
This function takes into account the sizes of every list fits every list in the given sizes. If some values are missing in a list, a zero vale casted to the type T is assed to the function.
Parameters
values
functiona lambda function that takes an argument of type T as input.
sizes

The documentation for this class was generated from the following file: