DGtal 1.4.0
Loading...
Searching...
No Matches
testSTLMapToVertexMapAdapter.cpp File Reference
#include <iostream>
#include <vector>
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include "DGtal/graph/CVertexMap.h"
#include "DGtal/graph/STLMapToVertexMapAdapter.h"
#include <map>
Include dependency graph for testSTLMapToVertexMapAdapter.cpp:

Go to the source code of this file.

Functions

bool testMapToVertexMap ()
 
int main (int, char **)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Jérémy Gaillard (jerem.nosp@m.y.ga.nosp@m.illar.nosp@m.d@in.nosp@m.sa-ly.nosp@m.on.f.nosp@m.r ) Institut National des Sciences Appliquées - INSA, France
Date
2012/07/12

Functions for testing class STLMapToVertexMapAdapter.

This file is part of the DGtal library.

Definition in file testSTLMapToVertexMapAdapter.cpp.

Function Documentation

◆ main()

int main ( int ,
char **  )

Definition at line 77 of file testSTLMapToVertexMapAdapter.cpp.

78{
79 trace.beginBlock ( "Testing class STLMapToVertexMapAdapter" );
80
81 bool res = testMapToVertexMap(); // && ... other tests
82 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
84 return res ? 0 : 1;
85}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
double endBlock()
Trace trace
Definition Common.h:153
bool testMapToVertexMap()

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), testMapToVertexMap(), and DGtal::trace.

◆ testMapToVertexMap()

bool testMapToVertexMap ( )

This file tests the adaptation of a STL map to a vertex map.

Definition at line 57 of file testSTLMapToVertexMapAdapter.cpp.

58{
59 typedef Z2i::Point Point;
60 typedef Z2i::Point Vertex;
61 typedef int Value;
62 typedef map<Vertex, Value> Map;
63 typedef STLMapToVertexMapAdapter<Map> VertexMap;
64 VertexMap myMap;
65 BOOST_CONCEPT_ASSERT((CVertexMap<VertexMap>));
66 myMap.setValue(Point(1,1), 10);
67 myMap.setValue(Point(2,3), 2);
68
69 return (myMap(Point(1,1)) == 10 && myMap(Point(2,3)) == 2);
70}
Aim: This class adapts any map of the STL to match with the CVertexMap concept.
Aim: models of CVertexMap concept implement mapping between graph vertices and values.
Definition CVertexMap.h:98
MyPointD Point
std::unordered_map< Cell, CubicalCellData > Map
TriMesh::Vertex Vertex

Referenced by main().