All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | List of all members
blaze::PtrVector< T, D, G >::CastIterator< C > Class Template Reference

Dynamic cast iterator for polymorphic pointer vectors.The CastIterator class is part of the PtrVector class and represent a forward iterator over all elements of type C contained in a range of elements of type T, where C is a type derived from T. More...

#include <PtrVector.h>

Public Types

typedef std::forward_iterator_tag IteratorCategory
 The iterator category.
 
typedef C * ValueType
 Type of the underlying pointers.
 
typedef C * PointerType
 Pointer return type.
 
typedef C *const & ReferenceType
 Reference return type.
 
typedef ptrdiff_t DifferenceType
 Difference between two iterators.
 
typedef T *const * IteratorType
 Type of the internal pointer.
 
typedef IteratorCategory iterator_category
 The iterator category.
 
typedef ValueType value_type
 Type of the underlying pointers.
 
typedef PointerType pointer
 Pointer return type.
 
typedef ReferenceType reference
 Reference return type.
 
typedef DifferenceType difference_type
 Difference between two iterators.
 

Public Member Functions

Constructors
 CastIterator ()
 Default constructor for CastIterator.
 
 CastIterator (IteratorType begin, IteratorType end)
 Standard constructor for CastIterator. More...
 
template<typename Other >
 CastIterator (const CastIterator< Other > &it)
 Conversion constructor from different CastIterator instances. More...
 
Operators
CastIteratoroperator++ ()
 Pre-increment operator. More...
 
CastIterator operator++ (int)
 Post-increment operator. More...
 
Access operators
PointerType operator* () const
 Returns a handle to the element at the current iterator position. More...
 
PointerType operator-> () const
 Direct access to the element at the current iterator position. More...
 
Utility functions
const IteratorTypebase () const
 Direct access to the current memory location of the cast iterator. More...
 
const IteratorTypestop () const
 Direct access to the final memory location of the cast iterator. More...
 

Private Attributes

Member variables
IteratorType cur_
 Pointer to the current memory location.
 
IteratorType end_
 Pointer to the element one past the last element in the element range.
 

Detailed Description

template<typename T, typename D = PtrDelete, typename G = OptimalGrowth>
template<typename C>
class blaze::PtrVector< T, D, G >::CastIterator< C >

Dynamic cast iterator for polymorphic pointer vectors.

The CastIterator class is part of the PtrVector class and represent a forward iterator over all elements of type C contained in a range of elements of type T, where C is a type derived from T.

class A { ... };
class B : public class A { ... };
// Loop over all elements of type B within the range [begin..end)
for( ; begin!=end; ++begin )
...

Note: Using a CastIterator is computationally more expensive than using a standard iterator over all elements contained in the vector.

Constructor & Destructor Documentation

template<typename T , typename D , typename G >
template<typename C >
blaze::PtrVector< T, D, G >::CastIterator< C >::CastIterator ( IteratorType  begin,
IteratorType  end 
)
inline

Standard constructor for CastIterator.

Parameters
beginThe beginning of the element range.
endThe end of the element range.
template<typename T , typename D , typename G >
template<typename C >
template<typename Other >
blaze::PtrVector< T, D, G >::CastIterator< C >::CastIterator ( const CastIterator< Other > &  it)
inline

Conversion constructor from different CastIterator instances.

Parameters
itThe foreign CastIterator instance to be copied.

Member Function Documentation

template<typename T , typename D , typename G >
template<typename C >
const PtrVector< T, D, G >::BLAZE_TEMPLATE CastIterator< C >::IteratorType & blaze::PtrVector< T, D, G >::CastIterator< C >::base ( ) const
inline

Direct access to the current memory location of the cast iterator.

Returns
Pointer to the current memory location.
template<typename T , typename D , typename G >
template<typename C >
PtrVector< T, D, G >::BLAZE_TEMPLATE CastIterator< C >::PointerType blaze::PtrVector< T, D, G >::CastIterator< C >::operator* ( ) const
inline

Returns a handle to the element at the current iterator position.

Returns
Handle to the element at the current iterator position.
template<typename T , typename D , typename G >
template<typename C >
PtrVector< T, D, G >::BLAZE_TEMPLATE CastIterator< C > & blaze::PtrVector< T, D, G >::CastIterator< C >::operator++ ( )
inline

Pre-increment operator.

Returns
Reference to the incremented cast iterator.
template<typename T , typename D , typename G >
template<typename C >
PtrVector< T, D, G >::BLAZE_TEMPLATE CastIterator< C > blaze::PtrVector< T, D, G >::CastIterator< C >::operator++ ( int  )
inline

Post-increment operator.

Returns
The incremented cast iterator.
template<typename T , typename D , typename G >
template<typename C >
PtrVector< T, D, G >::BLAZE_TEMPLATE CastIterator< C >::PointerType blaze::PtrVector< T, D, G >::CastIterator< C >::operator-> ( ) const
inline

Direct access to the element at the current iterator position.

Returns
Reference to the element at the current iterator position.
template<typename T , typename D , typename G >
template<typename C >
const PtrVector< T, D, G >::BLAZE_TEMPLATE CastIterator< C >::IteratorType & blaze::PtrVector< T, D, G >::CastIterator< C >::stop ( ) const
inline

Direct access to the final memory location of the cast iterator.

Returns
Pointer to the final memory location.

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