34 #include <forward_list>
36 #include "DGtal/base/Common.h"
37 #include "DGtal/base/IteratorCirculatorTraits.h"
38 #include "DGtal/base/Circulator.h"
39 #include "DGtal/base/ReverseIterator.h"
40 #include "DGtal/base/BasicFunctors.h"
41 #include "DGtal/base/ConstIteratorAdapter.h"
42 #include "DGtal/base/IteratorAdapter.h"
46 using namespace DGtal;
57 template<
typename IC,
typename T>
60 return boost::is_same<
70 template<
typename IC,
typename T>
73 return boost::is_same<
84 unsigned int nbok = 0;
87 trace.
beginBlock (
"Testing tags for various (circular) iterators..." );
90 trace.
info() <<
"forward list" << std::endl;
91 std::forward_list<int> fl;
95 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
99 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
104 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
108 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
116 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
120 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
125 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
129 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
137 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
141 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
146 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
150 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
153 trace.
info() <<
"basic array" << std::endl;
154 int t[5] = {1, 2, 3, 4, 5};
158 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
162 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
167 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
171 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
184 unsigned int nbok = 0;
187 trace.
beginBlock (
"Testing tags for adapters (ReverseIterator, (Const)IteratorAdapter) " );
189 int t[5] = {1, 2, 3, 4, 5};
191 trace.
info() <<
"ReverseIterator" << std::endl;
197 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
201 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
203 trace.
info() <<
"ConstIteratorAdapter" << std::endl;
209 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
213 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
215 trace.
info() <<
"IteratorAdapter" << std::endl;
221 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
225 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
231 trace.
info() <<
"ReverseIterator<Circulator> and Circulator<ReverseIterator>" << std::endl;
236 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
240 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
245 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
249 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
252 trace.
info() <<
"ConstIteratorAdapter of Circulator and Circulator of ConstIteratorAdapter" << std::endl;
257 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
261 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
266 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
270 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
273 trace.
info() <<
"IteratorAdapter of Circulator and Circulator of IteratorAdapter" << std::endl;
278 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
282 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
287 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
291 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
301 int main(
int argc,
char** argv )
305 for (
int i = 0; i < argc; ++i )
311 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
This class adapts any iterator so that operator* returns another element than the one pointed to by t...
This class adapts any lvalue iterator so that operator* returns a member on the element pointed to by...
This class adapts any bidirectional iterator so that operator++ calls operator-- and vice versa.
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
ToDGtalCategory< typename boost::iterator_category< IC >::type >::Category Category
Aim: Define a simple default functor that just returns its argument.
bool compareCategory(IC, T)
int main(int argc, char **argv)
bool testIteratorCirculatorTraits()
bool testIteratorCirculatorTraitsAndAdapters()