DGtal 1.4.0
Loading...
Searching...
No Matches
STLMapToVertexMapAdapter.h
1
17#pragma once
18
31#if defined(STLMapToVertexMapAdapter_RECURSES)
32#error Recursive header files inclusion detected in STLMapToVertexMapAdapter.h
33#else // defined(STLMapToVertexMapAdapter_RECURSES)
35#define STLMapToVertexMapAdapter_RECURSES
36
37#if !defined STLMapToVertexMapAdapter_h
39#define STLMapToVertexMapAdapter_h
40
42// Inclusions
43#include "DGtal/base/Common.h"
45
46namespace DGtal
47{
48
50 // template class STLMapToVertexMapAdapter
60 template < typename TMap >
62 public TMap
63 {
64 // ----------------------- Associated types ------------------------------
65 public:
67 typedef TMap Container;
68 typedef typename Container::value_compare Compare;
69 typedef typename Container::allocator_type Allocator;
70 typedef typename Container::key_type Vertex;
71 typedef typename Container::mapped_type Value;
72
73
74 // Cannot check this since some types using it are incomplete.
75 // BOOST_CONCEPT_ASSERT(( CUndirectedSimpleLocalGraph< Graph > ));
76 // BOOST_CONCEPT_ASSERT(( CSet< MarkSet, Vertex > ));
77
78
79 // ----------------------- Standard services ------------------------------
80 public:
81
83
84 template <class InputIterator> STLMapToVertexMapAdapter( InputIterator first,
85 InputIterator last, const Compare& comp = Compare(), const Allocator& alloc = Allocator() )
86 : Container( first, last, comp, alloc ) {}
87
90
91 void setValue(Vertex v, Value val)
92 {
93 (*this)[v] = val;
94 }
95
97 {
98 typename Container::const_iterator it = Container::find(v);
99 ASSERT( it != this->end() );
100 return it->second;
101 }
102
103 }; // end of class STLMapToVertexMapAdapter
104
105
106
107
108} // namespace DGtal
109
110
111
112#endif // !defined STLMapToVertexMapAdapter_h
113
114#undef STLMapToVertexMapAdapter_RECURSES
115#endif // else defined(STLMapToVertexMapAdapter_RECURSES)
Aim: This class adapts any map of the STL to match with the CVertexMap concept.
STLMapToVertexMapAdapter(InputIterator first, InputIterator last, const Compare &comp=Compare(), const Allocator &alloc=Allocator())
STLMapToVertexMapAdapter< TMap > Self
STLMapToVertexMapAdapter(STLMapToVertexMapAdapter &other)
DGtal is the top-level namespace which contains all DGtal functions and types.