HDK
|
#include <iterator.h>
Public Types | |
typedef Tf_IteratorInterface < T, Reverse > | IterInterface |
typedef IterInterface::IteratorType | Iterator |
typedef std::iterator_traits < Iterator >::reference | Reference |
Public Member Functions | |
TfIterator () | |
Default constructor. This iterator is uninitialized. More... | |
TfIterator (T &container) | |
TfIterator (T &&container) | |
Allow rvalues only if the container type T should be copied by TfIterator. More... | |
TfIterator (Iterator const &begin, Iterator const &end) | |
bool | operator! () const |
bool | operator== (const TfIterator &iterator) const |
bool | operator!= (const TfIterator &iterator) const |
TfIterator & | operator++ () |
TfIterator | operator++ (int) |
Reference | operator* () |
Reference | operator* () const |
Iterator & | operator-> () |
operator bool () const | |
operator Iterator () const | |
const Iterator & | base () const |
TfIterator | GetNext () const |
A simple iterator adapter for STL
containers.
TfIterator
iterates over the elements in an STL
container, according to the semantics of the simple iterator pattern. The following examples compare the TfIterator
to STL
, highlighting the brevity of the TfIterator
interface.
Note that using the TF_FOR_ALL()
macro, even more brevity is possible. For example, to print out all items of a set<int>
s
, we could write
Typically, a TfIterator
is used to traverse all of the elements in an STL
container. For ordered sets, other uses include iterating over a subset of the elements in the container, and using a TfIterator
as a sentinel.
The simple iterator pattern generalizes pointer semantics to traverse a set of elements, much like STL
iterators. However, the simple iterator pattern subscribes to a simpler subset of pointer operations: pointer assignment (operator=
), auto-increment (operator++
), dereferencing (operator*
), redirection (operator->
), and null pointer comparison (operator!
and operator
bool
). The simpler interface improves code legibility for the typical set traversals for which iterators are most commonly used. It is particularly useful for specifying iterators over sets of elements that are maintained by a user object, since the interface calls for only one GetIterator()
entry point rather than dual begin()
and end()
calls. This is especially desirable when the object owns many different sets.
T | container type |
Definition at line 159 of file iterator.h.
typedef IterInterface::IteratorType TfIterator< T, Reverse >::Iterator |
Definition at line 176 of file iterator.h.
typedef Tf_IteratorInterface<T, Reverse> TfIterator< T, Reverse >::IterInterface |
Definition at line 175 of file iterator.h.
typedef std::iterator_traits<Iterator>::reference TfIterator< T, Reverse >::Reference |
Definition at line 178 of file iterator.h.
|
inline |
Default constructor. This iterator is uninitialized.
Definition at line 181 of file iterator.h.
|
inline |
Constructs an iterator to traverse each element of the specified STL
container object.
container | container object |
Definition at line 186 of file iterator.h.
|
inline |
Allow rvalues only if the container type T should be copied by TfIterator.
Definition at line 189 of file iterator.h.
|
inline |
Constructs an iterator to traverse a subset of the elements in a container. This iterator is exhausted when it reaches the end iterator.
begin | iterator at the beginning of the sequence |
end | iterator at the end of the sequence |
Definition at line 203 of file iterator.h.
|
inline |
Returns an STL
iterator that has the same position as this iterator.
STL
iterator at the same position as this iterator Definition at line 290 of file iterator.h.
|
inline |
Returns an iterator that is positioned at the next element in the sequence.
Definition at line 297 of file iterator.h.
|
inlineexplicit |
Explicit bool conversion operator. The Iterator object converts to true if it has not been exhausted.
Definition at line 276 of file iterator.h.
|
inline |
Returns an STL
iterator that has the same position as this iterator.
STL
iterator at the same position as this iterator Definition at line 283 of file iterator.h.
|
inline |
Returns true if this iterator is exhausted.
Definition at line 210 of file iterator.h.
|
inline |
Returns false if (*this == iterator) returns true, returns true otherwise.
Definition at line 224 of file iterator.h.
|
inline |
Returns the element referenced by this iterator.
Definition at line 252 of file iterator.h.
|
inline |
Returns the element referenced by this iterator.
Definition at line 260 of file iterator.h.
|
inline |
Pre-increment operator. Advances this iterator to the next element in the sequence.
Definition at line 231 of file iterator.h.
|
inline |
Post-increment operator. Advances this iterator to the next element in the sequence, and returns a copy of this iterator prior to the increment.
Definition at line 244 of file iterator.h.
|
inline |
Returns a pointer to the element referenced by this iterator.
Definition at line 268 of file iterator.h.
|
inline |
Returns true if this Iterator.has the same position in the sequence as the specified iterator. The end of the sequence need not be the same.
iterator | iterator to compare |
Definition at line 218 of file iterator.h.