Map Adaptors
The same group on the Doxygen site.
- group Map Adaptors
Tools to create new maps from existing ones.
This group contains map adaptors that are used to create “implicit” maps from other maps.
Most of them are read-only maps. They can make arithmetic and logical operations between one or two maps (negation, shifting, addition, multiplication, logical ‘and’, ‘or’, ‘not’ etc.) or e.g. convert a map to another one of different Value type.
The typical usage of this classes is passing implicit maps to algorithms. If a function type algorithm is called then the function type map adaptors can be used comfortable. For example let’s see the usage of map adaptors with the
graphToEps()function.TheColor nodeColor( int deg ) { if( deg >= 2 ) { return( Color( 0.5 , 0.0 , 0.5 ) ); } else if( deg == 1 ) { return( Color( 1.0 , 0.5 , 1.0 ) ); } else { return( Color( 0.0 , 0.0 , 0.0 ) ); } } Digraph::NodeMap< int > degree_map( graph ); graphToEps( graph , "graph.eps" ) .coords( coords ) .scaleToA4() .undirected() .nodeColors( composeMap( functorToMap( nodeColor ) , degree_map ) ) .run();
functorToMap()function makes aninttoColormap from thenodeColor()function. ThecomposeMap()compose thedegree_mapand the previously created map. The composed map is a proper function to get the color of each node.The usage with class type algorithms is little bit harder. In this case the function type map adaptors can not be used, because the function map adaptors give back temporary objects.
We have a length map and a maximum speed map on the arcs of a digraph. The minimum time to pass the arc can be calculated as the division of the two maps which can be done implicitly with theDigraph graph; typedef Digraph::ArcMap< double > DoubleArcMap; DoubleArcMap length( graph ); DoubleArcMap speed( graph ); typedef DivMap< DoubleArcMap , DoubleArcMap > TimeMap; TimeMap time( length , speed ); Dijkstra< Digraph , TimeMap > dijkstra( graph , time ); dijkstra.run( source , target );
DivMaptemplate class. We use the implicit minimum time map as the length map of theDijkstraalgorithm.
Classes
Class |
Description |
|---|---|
Composition of two maps. |
|
Converts an STL style (unary) functor to a map. |
|
Converts a map to an STL style (unary) functor. |
|
Map adaptor to convert the Value type of a map to another type using the default conversion. |
|
Applies all map setting operations to two maps. |
|
Sum of two maps. |
|
Difference of two maps. |
|
Product of two maps. |
|
Quotient of two maps. |
|
Shifts a map with a constant. |
|
Shifts a map with a constant (read-write version). |
|
Scales a map with a constant. |
|
Scales a map with a constant (read-write version). |
|
Negative of a map. |
|
Negative of a map (read-write version). |
|
Absolute value of a map. |
|
Logical ‘and’ of two maps. |
|
Logical ‘or’ of two maps. |
|
Logical ‘not’ of a map. |
|
Logical ‘not’ of a map (read-write version). |
|
Combination of two maps using the == operator. |
|
Combination of two maps using the < operator. |
Functions and other members
-
template< typename M1 , typename M2 , typename F >
inline CombineMap< M1 , M2 , F , typename _maps_bits::CombineValue< M1 , M2 , F >::type > combineMap(
)
-
template< typename M1 , typename M2 , typename K1 , typename K2 , typename V >
inline CombineMap< M1 , M2 , V (*)(K1, K2) , V > combineMap(
)
-
template< typename F >
inline FunctorToMap< F , typename F::argument_type , typename F::result_type > functorToMap( - const F & f