FreePOOMA  2.4.1
Public Types | Public Member Functions | Protected Attributes | Friends
DerefIterator< T > Class Template Reference

DerefIterator<T> and ConstDerefIterator<T> are STL-style iterators that are used to properly handle iterating through lists of pointers. More...

#include <DerefIterator.h>

List of all members.

Public Types

typedef T Value_t
typedef std::vector< T * > List_t
typedef DerefIterator< Value_titerator
typedef ConstDerefIterator
< Value_t
const_iterator
typedef
std::random_access_iterator_tag 
iterator_category
typedef Value_t value_type
typedef ptrdiff_t difference_type
typedef Value_tpointer
typedef Value_treference

Public Member Functions

 DerefIterator ()
 DerefIterator (typename List_t::iterator x)
reference operator* () const
pointer operator-> () const
iteratoroperator++ ()
iterator operator++ (int)
iteratoroperator-- ()
iterator operator-- (int)
iteratoroperator+= (const difference_type i)
iteratoroperator-= (const difference_type i)
iterator operator+ (const difference_type i) const
iterator operator- (const difference_type i) const
difference_type operator- (const iterator &x) const
difference_type operator- (const const_iterator &x) const
reference operator[] (const difference_type i) const
bool operator== (const iterator &x) const
bool operator== (const const_iterator &x) const
bool operator< (const iterator &x) const
bool operator< (const const_iterator &x) const
bool operator!= (const iterator &y) const
bool operator> (const iterator &y) const
bool operator<= (const iterator &y) const
bool operator>= (const iterator &y) const
bool operator!= (const const_iterator &y) const
bool operator> (const const_iterator &y) const
bool operator<= (const const_iterator &y) const
bool operator>= (const const_iterator &y) const

Protected Attributes

List_t::iterator p_m

Friends

class ConstDerefIterator< T >
iterator operator+ (const difference_type n, const iterator &iter)

Detailed Description

template<class T>
class DerefIterator< T >

DerefIterator<T> and ConstDerefIterator<T> are STL-style iterators that are used to properly handle iterating through lists of pointers.

Not only is this a convenience, as these iterators automatically dereference themselves, it also solves a problem with const correctness. If one has vector<T*>::const_iterator, this only keeps the user from modifying the pointer, not from modifying the object that is pointed to. What one really wants is vector<const T*>::const_iterator, but that is not something one can get from vector<T*>.


Member Typedef Documentation

template<class T >
typedef T DerefIterator< T >::Value_t
template<class T >
typedef std::vector<T*> DerefIterator< T >::List_t
template<class T >
typedef DerefIterator<Value_t> DerefIterator< T >::iterator
template<class T >
typedef ConstDerefIterator<Value_t> DerefIterator< T >::const_iterator
template<class T >
typedef std::random_access_iterator_tag DerefIterator< T >::iterator_category
template<class T >
typedef Value_t DerefIterator< T >::value_type
template<class T >
typedef ptrdiff_t DerefIterator< T >::difference_type
template<class T >
typedef Value_t* DerefIterator< T >::pointer
template<class T >
typedef Value_t& DerefIterator< T >::reference

Constructor & Destructor Documentation

template<class T >
DerefIterator< T >::DerefIterator ( ) [inline]
template<class T >
DerefIterator< T >::DerefIterator ( typename List_t::iterator  x) [inline]

Member Function Documentation

template<class T >
reference DerefIterator< T >::operator* ( ) const [inline]
template<class T >
pointer DerefIterator< T >::operator-> ( ) const [inline]
template<class T >
iterator& DerefIterator< T >::operator++ ( ) [inline]
template<class T >
iterator DerefIterator< T >::operator++ ( int  ) [inline]
template<class T >
iterator& DerefIterator< T >::operator-- ( ) [inline]
template<class T >
iterator DerefIterator< T >::operator-- ( int  ) [inline]
template<class T >
iterator& DerefIterator< T >::operator+= ( const difference_type  i) [inline]
template<class T >
iterator& DerefIterator< T >::operator-= ( const difference_type  i) [inline]
template<class T >
iterator DerefIterator< T >::operator+ ( const difference_type  i) const [inline]
template<class T >
iterator DerefIterator< T >::operator- ( const difference_type  i) const [inline]
template<class T >
difference_type DerefIterator< T >::operator- ( const iterator x) const [inline]
template<class T >
difference_type DerefIterator< T >::operator- ( const const_iterator x) const [inline]
template<class T >
reference DerefIterator< T >::operator[] ( const difference_type  i) const [inline]
template<class T >
bool DerefIterator< T >::operator== ( const iterator x) const [inline]
template<class T >
bool DerefIterator< T >::operator== ( const const_iterator x) const [inline]
template<class T >
bool DerefIterator< T >::operator< ( const iterator x) const [inline]
template<class T >
bool DerefIterator< T >::operator< ( const const_iterator x) const [inline]
template<class T >
bool DerefIterator< T >::operator!= ( const iterator y) const [inline]
template<class T >
bool DerefIterator< T >::operator> ( const iterator y) const [inline]
template<class T >
bool DerefIterator< T >::operator<= ( const iterator y) const [inline]
template<class T >
bool DerefIterator< T >::operator>= ( const iterator y) const [inline]
template<class T >
bool DerefIterator< T >::operator!= ( const const_iterator y) const [inline]
template<class T >
bool DerefIterator< T >::operator> ( const const_iterator y) const [inline]
template<class T >
bool DerefIterator< T >::operator<= ( const const_iterator y) const [inline]
template<class T >
bool DerefIterator< T >::operator>= ( const const_iterator y) const [inline]

Friends And Related Function Documentation

template<class T >
friend class ConstDerefIterator< T > [friend]
template<class T >
iterator operator+ ( const difference_type  n,
const iterator iter 
) [friend]

Member Data Documentation

template<class T >
List_t::iterator DerefIterator< T >::p_m [protected]

The documentation for this class was generated from the following file: