34 #include "DGtal/base/Common.h"
35 #include "DGtal/base/IteratorFunctions.h"
36 #include "DGtal/base/Circulator.h"
37 #include "DGtal/base/ReverseIterator.h"
41 using namespace DGtal;
46 template<
typename Container,
typename T>
49 static void add(Container& c,
const T& obj)
55 #include <forward_list>
58 struct Tool<std::forward_list<int>, T>
60 static void add(std::forward_list<int>& c,
const T& obj)
71 template<
typename Container>
74 unsigned int nbok = 0;
80 typedef typename Container::iterator I;
82 trace.
info() <<
typeid(Category()).name() << std::endl;
98 if ( (i != c.begin()) && ( i == res ) )
101 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
115 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
128 template<
typename Container>
131 unsigned int nbok = 0;
137 typedef typename Container::iterator I;
139 trace.
info() <<
typeid(Category()).name() << std::endl;
141 trace.
info() <<
"empty underlying range" << std::endl;
142 if (
rangeSize(c.begin(), c.end()) == 0 )
145 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
150 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
154 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
159 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
164 trace.
info() <<
"underlying range of one element" << std::endl;
165 if (
rangeSize(c.begin(), c.end()) == 1 )
168 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
182 trace.
info() <<
"two equal iterators" << std::endl;
183 if (
rangeSize(c.begin(), c.begin()) == 0 )
186 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
190 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
195 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
198 trace.
info() <<
"whole range (of 7 elements)" << std::endl;
199 if (
rangeSize(c.begin(), c.end()) == 7 )
202 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
207 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
210 I itb = c.begin(); ++itb;
212 ite++; ite++; ite++; ite++;
214 trace.
info() <<
"subrange (of 4 elements)" << std::endl;
218 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
223 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
227 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
232 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
246 template<
typename Container>
249 unsigned int nbok = 0;
255 typedef typename Container::iterator I;
257 trace.
info() <<
typeid(Category()).name() << std::endl;
259 trace.
info() <<
"empty underlying range" << std::endl;
260 if (
rangeMiddle(c.begin(), c.end()) == c.begin() )
263 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
269 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
273 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
279 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
284 trace.
info() <<
"underlying range of one element" << std::endl;
285 if (
rangeMiddle(c.begin(), c.end()) == c.begin() )
288 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
294 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
305 trace.
info() <<
"two equal iterators" << std::endl;
306 if (
rangeMiddle(c.begin(), c.begin()) == c.begin() )
309 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
313 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
319 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
325 ite++; ite++; ite++; ite++;
327 res1++; res1++; res1++;
331 trace.
info() <<
"whole range with odd number of elements" << std::endl;
335 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
341 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
343 trace.
info() <<
"whole range with even number of elements" << std::endl;
347 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
353 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
361 trace.
info() <<
"subrange with odd number of elements" << std::endl;
365 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
371 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
375 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
381 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
386 trace.
info() <<
"subrange with even number of elements" << std::endl;
390 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
396 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
400 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
406 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
416 template<
typename IC>
419 return (isNotEmpty(itb,ite) == aFlagIsNotEmpty );
427 template<
typename Container>
430 unsigned int nbok = 0;
436 typedef typename Container::iterator I;
438 trace.
info() <<
typeid(Category()).name() << std::endl;
440 trace.
info() <<
"empty underlying range" << std::endl;
444 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
449 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
454 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
459 trace.
info() <<
"underlying range of one element" << std::endl;
463 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
468 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
473 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
484 trace.
info() <<
"two equal iterators" << std::endl;
488 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
493 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
496 I itb = c.begin(); itb++;
501 trace.
info() <<
"whole range" << std::endl;
505 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
510 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
515 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
522 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
527 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
532 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
543 int main(
int argc,
char** argv )
547 for (
int i = 0; i < argc; ++i )
551 std::forward_list<int> fl;
569 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 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.
IteratorCirculatorTraits< IC >::Difference rangeSize(const IC &itb, const IC &ite)
IteratorCirculatorTraits< IC >::Difference subRangeSize(const IC &itb, const IC &ite)
IC subRangeMiddle(const IC &itb, const IC &ite)
IC rangeMiddle(const IC &itb, const IC &ite)
void advanceIterator(IC &ic, typename IteratorCirculatorTraits< IC >::Difference n)
ToDGtalCategory< typename boost::iterator_category< IC >::type >::Category Category
ch add(Point(102.2, 50.2))
bool testRange(Container c)
bool testAdvance(Container c)
int main(int argc, char **argv)
bool testIsNotEmpty(const IC &itb, const IC &ite, const bool &aFlagIsNotEmpty)
bool testMiddle(Container c)
bool testSize(Container c)