Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_TemplateIterator.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef SACADO_TEMPLATEITERATOR_HPP
11 #define SACADO_TEMPLATEITERATOR_HPP
12 
13 #include <vector>
14 #include <iterator>
15 
16 namespace Sacado {
17 
26  template <typename BaseT>
27  class TemplateIterator : public std::iterator<std::input_iterator_tag,
28  BaseT> {
29  public:
30 
33  typename std::vector< Teuchos::RCP<BaseT> >::iterator p) :
34  object_iterator(p) {}
35 
36  // No default constructor
37  // Use default copy constructor and copy assignment
38 
40  bool operator==(const TemplateIterator& t) const {
41  return object_iterator == t.objectIterator;
42  }
43 
45  bool operator!=(const TemplateIterator& t) const {
46  return object_iterator != t.object_iterator;
47  }
48 
51  operator*() const {
52  return *(*object_iterator);
53  }
54 
57  operator->() const {
58  return &(*(*object_iterator));
59  }
60 
64  return *this;
65  }
66 
69  TemplateIterator tmp = *this;
70  ++(*this);
71  return tmp;
72  }
73 
76  return *object_iterator;
77  }
78 
79  private:
80 
82  typename std::vector< Teuchos::RCP<BaseT> >::iterator object_iterator;
83 
84  };
85 
94  template <typename BaseT>
95  class ConstTemplateIterator : public std::iterator<std::input_iterator_tag,
96  BaseT> {
97  public:
98 
101  typename std::vector< Teuchos::RCP<BaseT> >::const_iterator p) :
102  object_iterator(p) {}
103 
104  // No default constructor
105  // Use default copy constructor and copy assignment
106 
108  bool operator==(const ConstTemplateIterator& t) const {
109  return object_iterator == t.objectIterator;
110  }
111 
113  bool operator!=(const ConstTemplateIterator& t) const {
114  return object_iterator != t.object_iterator;
115  }
116 
119  operator*() const {
120  return *(*object_iterator);
121  }
122 
125  operator->() const {
126  return &(*(*object_iterator));
127  }
128 
131  ++object_iterator;
132  return *this;
133  }
134 
137  ConstTemplateIterator tmp = *this;
138  ++(*this);
139  return tmp;
140  }
141 
144  return *object_iterator;
145  }
146 
147  private:
148 
150  typename std::vector< Teuchos::RCP<BaseT> >::const_iterator object_iterator;
151 
152  };
153 
154 }
155 
156 #endif
const char * p
std::vector< Teuchos::RCP< BaseT > >::iterator object_iterator
Underlying object iterator.
TemplateIterator(typename std::vector< Teuchos::RCP< BaseT > >::iterator p)
Constructor.
bool operator==(const ConstTemplateIterator &t) const
Equal operator.
bool operator!=(const ConstTemplateIterator &t) const
Not equal operator.
Sacado::TemplateIterator< BaseT >::pointer operator->() const
-&gt; operator
Teuchos::RCP< BaseT > rcp() const
Returns a reference counted pointer object.
std::vector< Teuchos::RCP< BaseT > >::const_iterator object_iterator
Underlying object iterator.
TemplateIterator & operator++()
Prefix ++.
ConstTemplateIterator operator++(int)
Postfix ++.
TemplateIterator operator++(int)
Postfix ++.
Sacado::ConstTemplateIterator< BaseT >::pointer operator->() const
-&gt; operator
Teuchos::RCP< BaseT > rcp() const
Returns a reference counted pointer object.
ConstTemplateIterator & operator++()
Prefix ++.
bool operator!=(const TemplateIterator &t) const
Not equal operator.
Sacado::ConstTemplateIterator< BaseT >::reference operator*() const
Dereference operator.
Sacado::TemplateIterator< BaseT >::reference operator*() const
Dereference operator.
bool operator==(const TemplateIterator &t) const
Equal operator.
ConstTemplateIterator(typename std::vector< Teuchos::RCP< BaseT > >::const_iterator p)
Constructor.