All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions
Map Adaptors
Maps

Detailed Description

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.

Color 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();

The functorToMap() function makes an int to Color map from the nodeColor() function. The composeMap() compose the degree_map and 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.

Digraph 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);

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 the DivMap template class. We use the implicit minimum time map as the length map of the Dijkstra algorithm.

Classes

class  ComposeMap< M1, M2 >
 Composition of two maps. More...
 
class  CombineMap< M1, M2, F, V >
 Combination of two maps using an STL (binary) functor. More...
 
class  FunctorToMap< F, K, V >
 Converts an STL style (unary) functor to a map. More...
 
class  MapToFunctor< M >
 Converts a map to an STL style (unary) functor. More...
 
class  ConvertMap< M, V >
 Map adaptor to convert the Value type of a map to another type using the default conversion. More...
 
class  ForkMap< M1, M2 >
 Applies all map setting operations to two maps. More...
 
class  AddMap< M1, M2 >
 Sum of two maps. More...
 
class  SubMap< M1, M2 >
 Difference of two maps. More...
 
class  MulMap< M1, M2 >
 Product of two maps. More...
 
class  DivMap< M1, M2 >
 Quotient of two maps. More...
 
class  ShiftMap< M, C >
 Shifts a map with a constant. More...
 
class  ShiftWriteMap< M, C >
 Shifts a map with a constant (read-write version). More...
 
class  ScaleMap< M, C >
 Scales a map with a constant. More...
 
class  ScaleWriteMap< M, C >
 Scales a map with a constant (read-write version). More...
 
class  NegMap< M >
 Negative of a map. More...
 
class  NegWriteMap< M >
 Negative of a map (read-write version) More...
 
class  AbsMap< M >
 Absolute value of a map. More...
 
class  AndMap< M1, M2 >
 Logical 'and' of two maps. More...
 
class  OrMap< M1, M2 >
 Logical 'or' of two maps. More...
 
class  NotMap< M >
 Logical 'not' of a map. More...
 
class  NotWriteMap< M >
 Logical 'not' of a map (read-write version) More...
 
class  EqualMap< M1, M2 >
 Combination of two maps using the == operator. More...
 
class  LessMap< M1, M2 >
 Combination of two maps using the < operator. More...
 

Functions

template<typename M1 , typename M2 >
ComposeMap< M1, M2 > composeMap (const M1 &m1, const M2 &m2)
 Returns a ComposeMap class.
 
template<typename M1 , typename M2 , typename F , typename V >
CombineMap< M1, M2, F, V > combineMap (const M1 &m1, const M2 &m2, const F &f)
 Returns a CombineMap class.
 
template<typename K , typename V , typename F >
FunctorToMap< F, K, V > functorToMap (const F &f)
 Returns a FunctorToMap class.
 
template<typename M >
MapToFunctor< M > mapToFunctor (const M &m)
 Returns a MapToFunctor class.
 
template<typename V , typename M >
ConvertMap< M, V > convertMap (const M &map)
 Returns a ConvertMap class.
 
template<typename M1 , typename M2 >
ForkMap< M1, M2 > forkMap (M1 &m1, M2 &m2)
 Returns a ForkMap class.
 
template<typename M1 , typename M2 >
AddMap< M1, M2 > addMap (const M1 &m1, const M2 &m2)
 Returns an AddMap class.
 
template<typename M1 , typename M2 >
SubMap< M1, M2 > subMap (const M1 &m1, const M2 &m2)
 Returns a SubMap class.
 
template<typename M1 , typename M2 >
MulMap< M1, M2 > mulMap (const M1 &m1, const M2 &m2)
 Returns a MulMap class.
 
template<typename M1 , typename M2 >
DivMap< M1, M2 > divMap (const M1 &m1, const M2 &m2)
 Returns a DivMap class.
 
template<typename M , typename C >
ShiftMap< M, C > shiftMap (const M &m, const C &v)
 Returns a ShiftMap class.
 
template<typename M , typename C >
ShiftWriteMap< M, C > shiftWriteMap (M &m, const C &v)
 Returns a ShiftWriteMap class.
 
template<typename M , typename C >
ScaleMap< M, C > scaleMap (const M &m, const C &v)
 Returns a ScaleMap class.
 
template<typename M , typename C >
ScaleWriteMap< M, C > scaleWriteMap (M &m, const C &v)
 Returns a ScaleWriteMap class.
 
template<typename M >
NegMap< M > negMap (const M &m)
 Returns a NegMap class.
 
template<typename M >
NegWriteMap< M > negWriteMap (M &m)
 Returns a NegWriteMap class.
 
template<typename M >
AbsMap< M > absMap (const M &m)
 Returns an AbsMap class.
 
template<typename M1 , typename M2 >
AndMap< M1, M2 > andMap (const M1 &m1, const M2 &m2)
 Returns an AndMap class.
 
template<typename M1 , typename M2 >
OrMap< M1, M2 > orMap (const M1 &m1, const M2 &m2)
 Returns an OrMap class.
 
template<typename M >
NotMap< M > notMap (const M &m)
 Returns a NotMap class.
 
template<typename M >
NotWriteMap< M > notWriteMap (M &m)
 Returns a NotWriteMap class.
 
template<typename M1 , typename M2 >
EqualMap< M1, M2 > equalMap (const M1 &m1, const M2 &m2)
 Returns an EqualMap class.
 
template<typename M1 , typename M2 >
LessMap< M1, M2 > lessMap (const M1 &m1, const M2 &m2)
 Returns an LessMap class.
 

Function Documentation

ComposeMap< M1, M2 > composeMap ( const M1 &  m1,
const M2 &  m2 
)
related

This function just returns a ComposeMap class.

If m1 and m2 are maps and the Value type of m2 is convertible to the Key of m1, then composeMap(m1,m2)[x] will be equal to m1[m2[x]].

CombineMap< M1, M2, F, V > combineMap ( const M1 &  m1,
const M2 &  m2,
const F &  f 
)
related

This function just returns a CombineMap class.

For example, if m1 and m2 are both maps with double values, then

is equivalent to

addMap(m1,m2)

This function is specialized for adaptable binary function classes and C++ functions.

FunctorToMap< F, K, V > functorToMap ( const F &  f)
related

This function just returns a FunctorToMap class.

This function is specialized for adaptable binary function classes and C++ functions.

MapToFunctor< M > mapToFunctor ( const M &  m)
related

This function just returns a MapToFunctor class.

ConvertMap< M, V > convertMap ( const M &  map)
related

This function just returns a ConvertMap class.

ForkMap< M1, M2 > forkMap ( M1 &  m1,
M2 &  m2 
)
related

This function just returns a ForkMap class.

AddMap< M1, M2 > addMap ( const M1 &  m1,
const M2 &  m2 
)
related

This function just returns an AddMap class.

For example, if m1 and m2 are both maps with double values, then addMap(m1,m2)[x] will be equal to m1[x]+m2[x].

SubMap< M1, M2 > subMap ( const M1 &  m1,
const M2 &  m2 
)
related

This function just returns a SubMap class.

For example, if m1 and m2 are both maps with double values, then subMap(m1,m2)[x] will be equal to m1[x]-m2[x].

MulMap< M1, M2 > mulMap ( const M1 &  m1,
const M2 &  m2 
)
related

This function just returns a MulMap class.

For example, if m1 and m2 are both maps with double values, then mulMap(m1,m2)[x] will be equal to m1[x]*m2[x].

DivMap< M1, M2 > divMap ( const M1 &  m1,
const M2 &  m2 
)
related

This function just returns a DivMap class.

For example, if m1 and m2 are both maps with double values, then divMap(m1,m2)[x] will be equal to m1[x]/m2[x].

ShiftMap< M, C > shiftMap ( const M &  m,
const C &  v 
)
related

This function just returns a ShiftMap class.

For example, if m is a map with double values and v is double, then shiftMap(m,v)[x] will be equal to m[x]+v.

ShiftWriteMap< M, C > shiftWriteMap ( M &  m,
const C &  v 
)
related

This function just returns a ShiftWriteMap class.

For example, if m is a map with double values and v is double, then shiftWriteMap(m,v)[x] will be equal to m[x]+v. Moreover it makes also possible to write the map.

ScaleMap< M, C > scaleMap ( const M &  m,
const C &  v 
)
related

This function just returns a ScaleMap class.

For example, if m is a map with double values and v is double, then scaleMap(m,v)[x] will be equal to v*m[x].

ScaleWriteMap< M, C > scaleWriteMap ( M &  m,
const C &  v 
)
related

This function just returns a ScaleWriteMap class.

For example, if m is a map with double values and v is double, then scaleWriteMap(m,v)[x] will be equal to v*m[x]. Moreover it makes also possible to write the map.

NegMap< M > negMap ( const M &  m)
related

This function just returns a NegMap class.

For example, if m is a map with double values, then negMap(m)[x] will be equal to -m[x].

NegWriteMap< M > negWriteMap ( M &  m)
related

This function just returns a NegWriteMap class.

For example, if m is a map with double values, then negWriteMap(m)[x] will be equal to -m[x]. Moreover it makes also possible to write the map.

AbsMap< M > absMap ( const M &  m)
related

This function just returns an AbsMap class.

For example, if m is a map with double values, then absMap(m)[x] will be equal to m[x] if it is positive or zero and -m[x] if m[x] is negative.

AndMap< M1, M2 > andMap ( const M1 &  m1,
const M2 &  m2 
)
related

This function just returns an AndMap class.

For example, if m1 and m2 are both maps with bool values, then andMap(m1,m2)[x] will be equal to m1[x]&&m2[x].

OrMap< M1, M2 > orMap ( const M1 &  m1,
const M2 &  m2 
)
related

This function just returns an OrMap class.

For example, if m1 and m2 are both maps with bool values, then orMap(m1,m2)[x] will be equal to m1[x]||m2[x].

NotMap< M > notMap ( const M &  m)
related

This function just returns a NotMap class.

For example, if m is a map with bool values, then notMap(m)[x] will be equal to !m[x].

NotWriteMap< M > notWriteMap ( M &  m)
related

This function just returns a NotWriteMap class.

For example, if m is a map with bool values, then notWriteMap(m)[x] will be equal to !m[x]. Moreover it makes also possible to write the map.

EqualMap< M1, M2 > equalMap ( const M1 &  m1,
const M2 &  m2 
)
related

This function just returns an EqualMap class.

For example, if m1 and m2 are maps with keys and values of the same type, then equalMap(m1,m2)[x] will be equal to m1[x]==m2[x].

LessMap< M1, M2 > lessMap ( const M1 &  m1,
const M2 &  m2 
)
related

This function just returns an LessMap class.

For example, if m1 and m2 are maps with keys and values of the same type, then lessMap(m1,m2)[x] will be equal to m1[x]<m2[x].