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 176 of file iterator.h.
typedef IterInterface::IteratorType TfIterator< T, Reverse >::Iterator |
Definition at line 193 of file iterator.h.
typedef Tf_IteratorInterface<T, Reverse> TfIterator< T, Reverse >::IterInterface |
Definition at line 192 of file iterator.h.
typedef std::iterator_traits<Iterator>::reference TfIterator< T, Reverse >::Reference |
Definition at line 195 of file iterator.h.
|
inline |
Default constructor. This iterator is uninitialized.
Definition at line 198 of file iterator.h.
|
inline |
Constructs an iterator to traverse each element of the specified STL
container object.
container | container object |
Definition at line 203 of file iterator.h.
|
inline |
Allow rvalues only if the container type T should be copied by TfIterator.
Definition at line 206 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 220 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 307 of file iterator.h.
|
inline |
Returns an iterator that is positioned at the next element in the sequence.
Definition at line 314 of file iterator.h.
|
inlineexplicit |
Explicit bool conversion operator. The Iterator object converts to true if it has not been exhausted.
Definition at line 293 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 300 of file iterator.h.
|
inline |
Returns true if this iterator is exhausted.
Definition at line 227 of file iterator.h.
|
inline |
Returns false if (*this == iterator) returns true, returns true otherwise.
Definition at line 241 of file iterator.h.
|
inline |
Returns the element referenced by this iterator.
Definition at line 269 of file iterator.h.
|
inline |
Returns the element referenced by this iterator.
Definition at line 277 of file iterator.h.
|
inline |
Pre-increment operator. Advances this iterator to the next element in the sequence.
Definition at line 248 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 261 of file iterator.h.
|
inline |
Returns a pointer to the element referenced by this iterator.
Definition at line 285 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 235 of file iterator.h.