BDE 4.14.0 Production release
Loading...
Searching...
No Matches
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 >

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 ()=default
 Destroy this object.
 
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
 Return a const reference to the functor of this object.
 
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.

Member Typedef Documentation

◆ difference_type

template<class FUNCTOR , class ITERATOR >
typedef Traits::difference_type bdlb::TransformIterator< FUNCTOR, ITERATOR >::difference_type

◆ iterator_category

template<class FUNCTOR , class ITERATOR >
typedef Traits::iterator_category bdlb::TransformIterator< FUNCTOR, ITERATOR >::iterator_category

◆ pointer

template<class FUNCTOR , class ITERATOR >
typedef Traits::pointer bdlb::TransformIterator< FUNCTOR, ITERATOR >::pointer

◆ reference

template<class FUNCTOR , class ITERATOR >
typedef Traits::reference bdlb::TransformIterator< FUNCTOR, ITERATOR >::reference

◆ value_type

template<class FUNCTOR , class ITERATOR >
typedef Traits::value_type bdlb::TransformIterator< FUNCTOR, ITERATOR >::value_type

Constructor & Destructor Documentation

◆ TransformIterator() [1/3]

template<class FUNCTOR , class ITERATOR >
bdlb::TransformIterator< FUNCTOR, ITERATOR >::TransformIterator ( bslma::Allocator basicAllocator)
inlineexplicit

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.

◆ TransformIterator() [2/3]

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

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.

◆ TransformIterator() [3/3]

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

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.

◆ ~TransformIterator()

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

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION_IF()

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   
)

◆ functor() [1/2]

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

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

◆ functor() [2/2]

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

◆ iterator() [1/2]

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

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

◆ iterator() [2/2]

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

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

◆ operator*() [1/2]

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

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:

FUNCTOR & functor()
Definition bdlb_transformiterator.h:874
ITERATOR & iterator()
Definition bdlb_transformiterator.h:881

◆ operator*() [2/2]

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

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:

◆ operator++()

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

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.

◆ operator+=()

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

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.

◆ operator--()

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

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.

◆ operator-=()

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

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.

◆ operator->() [1/2]

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

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:

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

◆ operator->() [2/2]

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

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:

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

◆ operator=()

template<class FUNCTOR , class ITERATOR >
TransformIterator< FUNCTOR, ITERATOR > & bdlb::TransformIterator< FUNCTOR, ITERATOR >::operator= ( const TransformIterator< FUNCTOR, ITERATOR > &  rhs)
inline

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

◆ operator[]() [1/2]

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

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])

◆ operator[]() [2/2]

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

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])

◆ swap()

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

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.


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