This file contains the defines the forall loops. More...
#include <config.h>
#include <iterator>
#include <utility>
Go to the source code of this file.
Namespaces | |
namespace | std |
STL namespace. | |
namespace | util |
Various utility classes for generic programming. | |
Defines | |
#define | forall(typed_var, cont) forall_range( typed_var, util::ForAll::make_range( cont ) ) |
Macro iterating over a standard container from cont.begin() to cont.end() or cont.first to cont.second if cont is a pair. | |
#define | forall_named(typed_var, cont, name) forall_range( typed_var, std::make_pair( (cont).begin_##name(), (cont).end_##name() ) ) |
Macro iterating avec a a container but from cont.begin_name() to cont.end_name() . | |
#define | forall_range(typed_var, range) |
Macro allowing for automatic iteration over range.first -> range.second (range being a std::pair). | |
#define | forall_reverse(typed_var, cont) forall_range( typed_var, util::ForAll::make_reverse_range( cont ) ) |
Macro iterating over a standard reversible container from cont.rbegin() to cont.rend() ot from std::reverse_iterator (cont.second) to std::reverse_iterator (cont.first) if cont is a pair. | |
Functions | |
template<typename T > | |
const T & | std::begin (const pair< T, T > &p) |
template<typename T > | |
const T & | std::end (const pair< T, T > &p) |
This file contains the defines the forall loops.
Forall allows to iterate on STL container or range.
Use examples:
std::vector<int> va; // ... Filling in va ... forall(int a, va) { cout << a << endl; }
This example shows how to iterate on a container returned by value by a function:
std::vector<int> create_vector(); // Now put the output of the function in a local variable std::vector<int> va = create_vector(); forall(int a, va) { cout << a << endl; }
Use example with range:
typedef std::vector<int>::iterator iterator; std::pair<iterator,iterator> extract(std::vector<int> v, int first, int last); std::vector<int> va; // ... Filling in va ... forall(int& i, extract(va, 2, 10)) { i += 5; cout << i << endl; }
In this example, the values in the vector are changed too.
Definition in file forall.h.
#define forall | ( | typed_var, | |||
cont | ) | forall_range( typed_var, util::ForAll::make_range( cont ) ) |
Macro iterating over a standard container from cont.begin()
to cont.end()
or cont.first
to cont.second
if cont
is a pair.
Definition at line 212 of file forall.h.
Referenced by vvcomplex::VVComplex< MANDATORY_COMPLEX_TEMPLATE_ARGS, RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >)>::addCellUnsorted(), vvcomplex::VVComplexGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), JunctionContent, graph::_EmptyEdgeContent, graph::_EmptyEdgeContent, false >::adjacentCells(), util::Parms::all(), vvcomplex::VVComplex< MANDATORY_COMPLEX_TEMPLATE_ARGS, RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >)>::border(), vvcomplex::VVComplexGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), JunctionContent, graph::_EmptyEdgeContent, graph::_EmptyEdgeContent, false >::border(), tissue::Tissue< Model, CellContent, JunctionContent, WallContent, CellEdgeContent, CellJunctionContent, JunctionCellContent, compact, LeafClass >::calcQuads(), vvcomplex::VVComplex< MANDATORY_COMPLEX_TEMPLATE_ARGS, RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >)>::connectFromJunctions(), algorithms::TriangleSurface::contour(), vvcomplex::VVComplexGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), JunctionContent, graph::_EmptyEdgeContent, graph::_EmptyEdgeContent, false >::deleteCell(), vvcomplex::VVComplex< MANDATORY_COMPLEX_TEMPLATE_ARGS, RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >)>::deleteCellInGraphs(), vvcomplex::VVComplex< MANDATORY_COMPLEX_TEMPLATE_ARGS, RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >)>::divideCell(), vvcomplex::VVComplexGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), JunctionContent, graph::_EmptyEdgeContent, graph::_EmptyEdgeContent, false >::divideCell(), tissue_model::TissueModel< RealModel, TissueClass >::draw(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::draw(), tissue::Tissue< Model, CellContent, JunctionContent, WallContent, CellEdgeContent, CellJunctionContent, JunctionCellContent, compact, LeafClass >::drawCell(), tissue::Tissue< Model, CellContent, JunctionContent, WallContent, CellEdgeContent, CellJunctionContent, JunctionCellContent, compact, LeafClass >::drawCellContour(), tissue::Tissue< Model, CellContent, JunctionContent, WallContent, CellEdgeContent, CellJunctionContent, JunctionCellContent, compact, LeafClass >::drawSimplifiedCell(), algorithms::drawSymetricVVGraph(), tissue::Tissue< Model, CellContent, JunctionContent, WallContent, CellEdgeContent, CellJunctionContent, JunctionCellContent, compact, LeafClass >::drawWalledCell(), vvcomplex::findCenter(), tissue::findDivisionPoints(), cell_system::findDivisionPoints(), vvcomplex::FindOppositeWall(), solver::Solver< nb_vars, identifier >::FindPartials(), complex_factory::hex_grid(), algorithms::TriangleGrowth::init(), vvcomplex::VVComplexGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), JunctionContent, graph::_EmptyEdgeContent, graph::_EmptyEdgeContent, false >::interfaceWall(), vvcomplex::VVComplexGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), JunctionContent, graph::_EmptyEdgeContent, graph::_EmptyEdgeContent, false >::interfaceWallSpan(), vvcomplex::VVComplex< MANDATORY_COMPLEX_TEMPLATE_ARGS, RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >)>::mergeCells(), vvcomplex::VVComplexGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), JunctionContent, graph::_EmptyEdgeContent, graph::_EmptyEdgeContent, false >::mergeCells(), complex_factory::objreader(), algorithms::TriangleSurface::position(), algorithms::TriangleGrowth::readOBJs(), storage::VVEStorage_XMLReader::setLastError(), solver::Solver< nb_vars, identifier >::solveAdaptiveCrankNicholson(), solver::Solver< nb_vars, identifier >::solveAdaptiveEuler(), solver::Solver< nb_vars, identifier >::solveAdaptiveRungeKutta(), solver::Solver< nb_vars, identifier >::solveEuler(), solver::Solver< nb_vars, identifier >::solveFixedpoint(), solver::Solver< nb_vars, identifier >::solveMidpoint(), solver::Solver< nb_vars, identifier >::solveRungeKutta(), vvcomplex::VVComplexGraph< RESOLVE_LEAF_CLASS(LeafClass, Tissue< ALL_COMPLEX_TEMPLATE_ARGS >), JunctionContent, graph::_EmptyEdgeContent, graph::_EmptyEdgeContent, false >::splitWall(), complex_factory::square_grid(), cell_system::CellSystem< TissueClass, RealModel >::step_cellsystem_division(), cell_system::CellSystem< TissueClass, RealModel >::step_cellsystem_meca(), tissue_model::TissueModel< RealModel, TissueClass >::updateCellsArea(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::updateCellsArea(), cell_system::CellSystem< TissueClass, RealModel >::updateCellsArea(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::updatePositions(), and util::WatchDog::watch().
#define forall_named | ( | typed_var, | |||
cont, | |||||
name | ) | forall_range( typed_var, std::make_pair( (cont).begin_##name(), (cont).end_##name() ) ) |
Macro iterating avec a a container but from cont.begin_name()
to cont.end_name()
.
cont
is evaluated twice! Definition at line 234 of file forall.h.
Referenced by tissue_model::TissueModel< RealModel, TissueClass >::draw(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::draw(), tissue_model::TissueModel< RealModel, TissueClass >::drawWithNames(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::drawWithNames(), complex_factory::objreader(), cell_system::CellSystem< TissueClass, RealModel >::step_cellsystem_meca(), tissue_model::TissueModel< RealModel, TissueClass >::updateCellsArea(), bspline_tissue_model::TissueModel< RealModel, TissueClass >::updateCellsArea(), and cell_system::CellSystem< TissueClass, RealModel >::updateCellsArea().
#define forall_range | ( | typed_var, | |||
range | ) |
for( const util::ForAll::BaseForwardIter& iter = util::ForAll::forwardIter( range, forall_pointer( (range).first ) ) ; \ !util::ForAll::castForwardIter( &iter, forall_pointer( (range).first ) )->is_end() ;\ ++( util::ForAll::castForwardIter( &iter, forall_pointer( (range).first ) )->it ) ) \ for( typed_var = util::ForAll::castForwardIter( &iter, forall_pointer( (range).first ) )->value() ; \ util::ForAll::castForwardIter( &iter, forall_pointer( (range).first ) )->brk ; \ --( util::ForAll::castForwardIter( &iter, forall_pointer( (range).first ) )->brk ) )
Macro allowing for automatic iteration over range.first
-> range.second
(range being a std::pair).
#define forall_reverse | ( | typed_var, | |||
cont | ) | forall_range( typed_var, util::ForAll::make_reverse_range( cont ) ) |
Macro iterating over a standard reversible container from cont.rbegin()
to cont.rend()
ot from std::reverse_iterator
(cont.second) to std::reverse_iterator
(cont.first) if cont
is a pair.