Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions

bdlb::TransformIterator< FUNCTOR, ITERATOR > Class Template Reference

#include <bdlb_transformiterator.h>

Inheritance diagram for bdlb::TransformIterator< FUNCTOR, ITERATOR >:
bdlb::TransformIterator_AllocatorOfIteratorMethod< TransformIterator< FUNCTOR, ITERATOR >, bslma::UsesBslmaAllocator< ITERATOR >::value > bdlb::TransformIterator_AllocatorOfFunctorMethod< TransformIterator< FUNCTOR, ITERATOR >,!bslma::UsesBslmaAllocator< ITERATOR >::value &&bslma::UsesBslmaAllocator< FUNCTOR >::value >

List of all members.

Public Types

typedef Traits::iterator_category iterator_category
typedef Traits::value_type value_type
typedef Traits::difference_type difference_type
typedef Traits::pointer pointer
typedef Traits::reference reference

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION_IF (TransformIterator, bslma::UsesBslmaAllocator, bslma::UsesBslmaAllocator< ITERATOR >::value||bslma::UsesBslmaAllocator< FUNCTOR >::value) TransformIterator()
 TransformIterator (bslma::Allocator *basicAllocator)
 TransformIterator (const ITERATOR &iterator, FUNCTOR functor, bslma::Allocator *basicAllocator=0)
 TransformIterator (const TransformIterator &original, bslma::Allocator *basicAllocator=0)
 ~TransformIterator ()
TransformIteratoroperator= (const TransformIterator &rhs)
TransformIteratoroperator+= (difference_type offset)
TransformIteratoroperator-= (difference_type offset)
TransformIteratoroperator++ ()
TransformIteratoroperator-- ()
reference operator* ()
pointer operator-> ()
reference operator[] (difference_type offset)
FUNCTOR & functor ()
ITERATOR & iterator ()
void swap (TransformIterator &other)
reference operator* () const
pointer operator-> () const
reference operator[] (difference_type offset) const
const FUNCTOR & functor () const
const ITERATOR & iterator () const

Detailed Description

template<class FUNCTOR, class ITERATOR>
class bdlb::TransformIterator< FUNCTOR, ITERATOR >

The transform iterator class itself. Its job is to hold a functor and an iterator, pass through all iterator-related operations to the held iterator, and on dereference, call the functor on the result of dereferencing the iterator and return the result of the call instead.

See Component bdlb_transformiterator


Member Typedef Documentation

template<class FUNCTOR, class ITERATOR>
typedef Traits::iterator_category bdlb::TransformIterator< FUNCTOR, ITERATOR >::iterator_category
template<class FUNCTOR, class ITERATOR>
typedef Traits::value_type bdlb::TransformIterator< FUNCTOR, ITERATOR >::value_type
template<class FUNCTOR, class ITERATOR>
typedef Traits::difference_type bdlb::TransformIterator< FUNCTOR, ITERATOR >::difference_type
template<class FUNCTOR, class ITERATOR>
typedef Traits::pointer bdlb::TransformIterator< FUNCTOR, ITERATOR >::pointer
template<class FUNCTOR, class ITERATOR>
typedef Traits::reference bdlb::TransformIterator< FUNCTOR, ITERATOR >::reference

Constructor & Destructor Documentation

template<class FUNCTOR, class ITERATOR>
bdlb::TransformIterator< FUNCTOR, ITERATOR >::TransformIterator ( bslma::Allocator basicAllocator  )  [explicit]

Create a TransformIterator object whose underlying iterator and functor have default values. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

template<class FUNCTOR, class ITERATOR>
bdlb::TransformIterator< FUNCTOR, ITERATOR >::TransformIterator ( const ITERATOR &  iterator,
FUNCTOR  functor,
bslma::Allocator basicAllocator = 0 
)

Create a TransformIterator object using the specified iterator and functor. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

template<class FUNCTOR, class ITERATOR>
bdlb::TransformIterator< FUNCTOR, ITERATOR >::TransformIterator ( const TransformIterator< FUNCTOR, ITERATOR > &  original,
bslma::Allocator basicAllocator = 0 
)

Create a TransformIterator object having the same value as the specified original object. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

template<class FUNCTOR, class ITERATOR>
bdlb::TransformIterator< FUNCTOR, ITERATOR >::~TransformIterator (  ) 

Destroy this object.


Member Function Documentation

template<class FUNCTOR, class ITERATOR>
bdlb::TransformIterator< FUNCTOR, ITERATOR >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( TransformIterator< FUNCTOR, ITERATOR >  ,
bslma::UsesBslmaAllocator  ,
bslma::UsesBslmaAllocator< ITERATOR >::value||bslma::UsesBslmaAllocator< FUNCTOR >::value   
)
template<class FUNCTOR, class ITERATOR>
TransformIterator& bdlb::TransformIterator< FUNCTOR, ITERATOR >::operator= ( const TransformIterator< FUNCTOR, ITERATOR > &  rhs  ) 

Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object.

template<class FUNCTOR, class ITERATOR>
TransformIterator& bdlb::TransformIterator< FUNCTOR, ITERATOR >::operator+= ( difference_type  offset  ) 

Advance the underlying iterator of this object by the specified (signed) offset, and return a reference providing modifiable access to this object. The behavior is undefined if so advancing the underlying iterator is undefined.

template<class FUNCTOR, class ITERATOR>
TransformIterator& bdlb::TransformIterator< FUNCTOR, ITERATOR >::operator-= ( difference_type  offset  ) 

Regress the underlying iterator of this object by the specified (signed) offset, and return a reference providing modifiable access to this object. The behavior is undefined if so regressing the underlying iterator is undefined.

template<class FUNCTOR, class ITERATOR>
TransformIterator& bdlb::TransformIterator< FUNCTOR, ITERATOR >::operator++ (  ) 

Increment the underlying iterator of this object, and return a reference providing modifiable access to this object. The behavior is undefined if incrementing the underlying iterator is undefined.

template<class FUNCTOR, class ITERATOR>
TransformIterator& bdlb::TransformIterator< FUNCTOR, ITERATOR >::operator-- (  ) 

Decrement the underlying iterator of this object, and return a reference providing modifiable access to this object. The behavior is undefined if decrementing the underlying iterator is undefined.

template<class FUNCTOR, class ITERATOR>
reference bdlb::TransformIterator< FUNCTOR, ITERATOR >::operator* (  ) 

Return the result of applying the functor of this object to the result of dereferencing the underlying iterator. The behavior is undefined if dereferencing the underlying iterator is undefined. Note that the behavior of this method is equivalent to:

template<class FUNCTOR, class ITERATOR>
pointer bdlb::TransformIterator< FUNCTOR, ITERATOR >::operator-> (  ) 

Return the address of the result of applying the functor of this object to the result of dereferencing the underlying iterator. The behavior is undefined if dereferencing the underlying iterator is undefined. Note that the behavior of this method is equivalent to:

          &functor()(*iterator())

Also note that the functor must return a reference type for this method to be used.

template<class FUNCTOR, class ITERATOR>
reference bdlb::TransformIterator< FUNCTOR, ITERATOR >::operator[] ( difference_type  offset  ) 

Return the result of applying the functor of this object to the result of dereferencing the underlying iterator advanced by the specified (signed) offset. The behavior is undefined if so advancing or dereferencing the underlying iterator is undefined. Note that the behavior of this method is equivalent to:

          functor()(iterator()[offset])
template<class FUNCTOR, class ITERATOR>
FUNCTOR& bdlb::TransformIterator< FUNCTOR, ITERATOR >::functor (  ) 

Return a reference providing modifiable access to the functor of this object.

template<class FUNCTOR, class ITERATOR>
ITERATOR& bdlb::TransformIterator< FUNCTOR, ITERATOR >::iterator (  ) 

Return a reference providing modifiable access to the underlying iterator of this object.

template<class FUNCTOR, class ITERATOR>
void bdlb::TransformIterator< FUNCTOR, ITERATOR >::swap ( TransformIterator< FUNCTOR, ITERATOR > &  other  ) 

Efficiently exchange the value of this object with the value of the specified other object by applying swap to each of the functor and underlying iterator fields of the two objects.

template<class FUNCTOR, class ITERATOR>
reference bdlb::TransformIterator< FUNCTOR, ITERATOR >::operator* (  )  const

Return the result of applying the functor of this object to the result of dereferencing the underlying iterator. The behavior is undefined if dereferencing the underlying iterator is undefined. Note that the behavior of this method is equivalent to:

template<class FUNCTOR, class ITERATOR>
pointer bdlb::TransformIterator< FUNCTOR, ITERATOR >::operator-> (  )  const

Return the address of the result of applying the functor of this object to the result of dereferencing the underlying iterator. The behavior is undefined if dereferencing the underlying iterator is undefined. Note that the behavior of this method is equivalent to:

          &functor()(*iterator())

Also note that the functor must return a reference type for this method to be used.

template<class FUNCTOR, class ITERATOR>
reference bdlb::TransformIterator< FUNCTOR, ITERATOR >::operator[] ( difference_type  offset  )  const

Return the result of applying the functor of this object to the result of dereferencing the underlying iterator advanced by the specified (signed) offset. The behavior is undefined if so advancing or dereferencing the underlying iterator is undefined. Note that the behavior of this method is equivalent to:

          functor()(iterator()[offset])
template<class FUNCTOR, class ITERATOR>
const FUNCTOR& bdlb::TransformIterator< FUNCTOR, ITERATOR >::functor (  )  const

Return a const reference to the functor of this object.

template<class FUNCTOR, class ITERATOR>
const ITERATOR& bdlb::TransformIterator< FUNCTOR, ITERATOR >::iterator (  )  const

Return a const reference to the underlying iterator of this object.


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