DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IteratorFunctions.h
1 
17 #pragma once
18 
31 #if defined(IteratorFunctions_RECURSES)
32 #error Recursive header files inclusion detected in IteratorFunctions.h
33 #else // defined(IteratorFunctions_RECURSES)
34 
35 #define IteratorFunctions_RECURSES
36 
37 #if !defined IteratorFunctions_h
38 
39 #define IteratorFunctions_h
40 
42 // Inclusions
43 #include<iterator>
44 
46 
47 namespace DGtal
48 {
49 
51  // template functions isNotEmpty
52 
53 namespace detail {
54 
55  template< typename IC >
56  inline
57  bool isNotEmpty( const IC& itb, const IC& ite, IteratorType ) {
58  return (itb != ite);
59  }
60 
61  template< typename IC >
62  inline
63  bool isNotEmpty( const IC& c1, const IC& c2, CirculatorType) {
64 // using isValid method does not work with reverse circulator
65 //(generally speaking adapters of circulators that does not have any isValid method)
66 // return ( ( c1.isValid() ) && ( c2.isValid() ) );
67  IC c; //c is not valid
68  return ( (c1 != c) && (c2 != c) );
69  }
70 
71 }
72 
73 template< typename IC>
74 inline
75 bool isEmpty( const IC& itb, const IC& ite ){
76  return !detail::isNotEmpty<IC>( itb, ite, typename IteratorCirculatorTraits<IC>::Type() );
77 }
78 
79 template< typename IC>
80 inline
81 bool isNotEmpty( const IC& itb, const IC& ite ){
82  return detail::isNotEmpty<IC>( itb, ite, typename IteratorCirculatorTraits<IC>::Type() );
83 }
84 
85 } // namespace DGtal
86 
87 
88 
89 
91 // Includes inline functions.
92 //#include "DGtal/base/IteratorFunctions.ih"
93 
94 // //
96 
97 #endif // !defined IteratorFunctions_h
98 
99 #undef IteratorFunctions_RECURSES
100 #endif // else defined(IteratorFunctions_RECURSES)