itunesdb::utils::SortablePtrVector< ElemType >::ContainerVersionAwareIterator< Container_T, Iter_T, TUnaryPredicate > Class Template Reference

#include <utils.h>

Inheritance diagram for itunesdb::utils::SortablePtrVector< ElemType >::ContainerVersionAwareIterator< Container_T, Iter_T, TUnaryPredicate >:

itunesdb::utils::RangeIterator< ElemType *, Iter_T, TUnaryPredicate > itunesdb::utils::SortablePtrVector< ElemType >::FilteredConstIterator< TUnaryPredicate > itunesdb::utils::SortablePtrVector< ElemType >::FilteredConstIterator< TrackPredicate_T > itunesdb::utils::SortablePtrVector< ElemType >::FilteredIterator< TUnaryPredicate > ITunesDB::FilteredTrackConstIterator< TrackPredicate_T > List of all members.

Public Member Functions

bool isValid () const
 Returns false if the underlying container got changed outside the control of this iterator, true otherwise.
bool hasNext () const
 Returns true if there are elements left so calling next() would return the next element rather than causing a segfault.
ElemType * next ()
 Returns the next element of the range of elements we iterate over.
ElemType * current () const
 Returns the element returned by the last next() call.
unsigned int remaining () const
 Returns the number of elements remaining in this iterator.
ElemType * last () const
 Returns the last element this iterator would return.

Protected Types

typedef RangeIterator< ElemType *,
Iter_T, TUnaryPredicate > 
BaseRangeIterator
 The base type of this iterator.

Protected Member Functions

 ContainerVersionAwareIterator (Container_T &container, const TUnaryPredicate &pred=TUnaryPredicate())
 Creates a new ContainerVersionAwareIterator.
void setRange (Iter_Tpos, Iter_Tend)
 Sets the range to the given iterators.
Iter_T currentPos ()
 Returns the iterator pointing to the element returned by the last next() call.
bool empty () const
 Returns true if there are no elements left to be iterated over.

Protected Attributes

Container_T & m_container
 The container we iterate over.
unsigned long m_containerversion
 The version of the container we iterate over.
DefaultDeref< ElemType *,
Iter_T > 
m_dereferenceFun
RangeIteratorFunctions< ElemType *,
Iter_T, TUnaryPredicate,
DefaultDeref< ElemType *,
Iter_T > > 
m_helper

Detailed Description

template<class ElemType>
template<typename Container_T, typename Iter_T, typename TUnaryPredicate = TRUEPredicate>
class itunesdb::utils::SortablePtrVector< ElemType >::ContainerVersionAwareIterator< Container_T, Iter_T, TUnaryPredicate >

An Iterator over all elements of this container being aware of changes to the container. The Iterator gets invalid if the container got changed outside the control of this iterator.


Member Typedef Documentation

template<class ElemType>
template<typename Container_T, typename Iter_T, typename TUnaryPredicate = TRUEPredicate>
typedef RangeIterator< ElemType*, Iter_T, TUnaryPredicate > itunesdb::utils::SortablePtrVector< ElemType >::ContainerVersionAwareIterator< Container_T, Iter_T, TUnaryPredicate >::BaseRangeIterator [protected]

The base type of this iterator.


Constructor & Destructor Documentation

template<class ElemType>
template<typename Container_T, typename Iter_T, typename TUnaryPredicate = TRUEPredicate>
itunesdb::utils::SortablePtrVector< ElemType >::ContainerVersionAwareIterator< Container_T, Iter_T, TUnaryPredicate >::ContainerVersionAwareIterator ( Container_T &  container,
const TUnaryPredicate &  pred = TUnaryPredicate() 
) [inline, protected]

Creates a new ContainerVersionAwareIterator.

The Iterator iterates over all elements in container matching the given predicate. The version of the iterator will be checked against the version of the given container to check the validity of this Iterator instance.

Parameters:
container the container to iterate over and to check the version against
pred the predicate to match the elements against


Member Function Documentation

template<class ElemType>
template<typename Container_T, typename Iter_T, typename TUnaryPredicate = TRUEPredicate>
bool itunesdb::utils::SortablePtrVector< ElemType >::ContainerVersionAwareIterator< Container_T, Iter_T, TUnaryPredicate >::isValid (  )  const [inline]

Returns false if the underlying container got changed outside the control of this iterator, true otherwise.

Returns:
false if the underlying container got changed outside the control of this iterator.

template<class ElemType>
template<typename Container_T, typename Iter_T, typename TUnaryPredicate = TRUEPredicate>
bool itunesdb::utils::SortablePtrVector< ElemType >::ContainerVersionAwareIterator< Container_T, Iter_T, TUnaryPredicate >::hasNext (  )  const [inline]

Returns true if there are elements left so calling next() would return the next element rather than causing a segfault.

Returns:
true if there are elements left

Reimplemented from itunesdb::utils::RangeIterator< ElemType *, Iter_T, TUnaryPredicate >.

Examples:
listtests.cpp.

void itunesdb::utils::RangeIterator< ElemType * , Iter_T , TUnaryPredicate , DefaultDeref< ElemType * , Iter_T > >::setRange ( Iter_T   pos,
Iter_T   end 
) [inline, protected, inherited]

Sets the range to the given iterators.

Iter_T itunesdb::utils::RangeIterator< ElemType * , Iter_T , TUnaryPredicate , DefaultDeref< ElemType * , Iter_T > >::currentPos (  )  [inline, protected, inherited]

Returns the iterator pointing to the element returned by the last next() call.

Returns:
the iterator pointing to the element returned by the last next() call

bool itunesdb::utils::RangeIterator< ElemType * , Iter_T , TUnaryPredicate , DefaultDeref< ElemType * , Iter_T > >::empty (  )  const [inline, protected, inherited]

Returns true if there are no elements left to be iterated over.

Returns:
true if there are no elements left to be iterated over

ElemType * itunesdb::utils::RangeIterator< ElemType * , Iter_T , TUnaryPredicate , DefaultDeref< ElemType * , Iter_T > >::next (  )  [inline, inherited]

Returns the next element of the range of elements we iterate over.

This method positions the Iterator at the next element and returns it. The first call to this method will return the first element of the range.
If the iterator is filtered only those elements where the given predicate returned true are returned.

Attention:
Always check if hasNext() returns true before calling next. Calling next() on an iterator already at the end of the range will cause a segfault.
Precondition:
hasNext() returns true
Postcondition:
a successive call to current() returns the element returned by this method
Examples:
listtests.cpp.

ElemType * itunesdb::utils::RangeIterator< ElemType * , Iter_T , TUnaryPredicate , DefaultDeref< ElemType * , Iter_T > >::current (  )  const [inline, inherited]

Returns the element returned by the last next() call.

Returns:
the element returned by the last next() call

unsigned int itunesdb::utils::RangeIterator< ElemType * , Iter_T , TUnaryPredicate , DefaultDeref< ElemType * , Iter_T > >::remaining (  )  const [inline, inherited]

Returns the number of elements remaining in this iterator.

... meaning the number of times the next() method can be called before the hasNext() method willreturn false. For filtered iterators this may be a lengthy operation since the iterator needs to apply its filter over all elements to determine how many elements are left.

Returns:
the number of elements left

ElemType * itunesdb::utils::RangeIterator< ElemType * , Iter_T , TUnaryPredicate , DefaultDeref< ElemType * , Iter_T > >::last (  )  const [inline, inherited]

Returns the last element this iterator would return.

This method is dangerous and makes no sense. Do not call this for empty iterators so at least check with hasNext() before.

Returns:
the last element this iterator would return
Precondition:
it must have been ensured that the iterator is nonempty


Member Data Documentation

template<class ElemType>
template<typename Container_T, typename Iter_T, typename TUnaryPredicate = TRUEPredicate>
Container_T& itunesdb::utils::SortablePtrVector< ElemType >::ContainerVersionAwareIterator< Container_T, Iter_T, TUnaryPredicate >::m_container [protected]

The container we iterate over.

We need this to check our version and validity against

template<class ElemType>
template<typename Container_T, typename Iter_T, typename TUnaryPredicate = TRUEPredicate>
unsigned long itunesdb::utils::SortablePtrVector< ElemType >::ContainerVersionAwareIterator< Container_T, Iter_T, TUnaryPredicate >::m_containerversion [protected]

The version of the container we iterate over.

If this differs from m_container.m_version the iterator gets invalid.

DefaultDeref< ElemType * , Iter_T > itunesdb::utils::RangeIterator< ElemType * , Iter_T , TUnaryPredicate , DefaultDeref< ElemType * , Iter_T > >::m_dereferenceFun [protected, inherited]

Dereferencer to dereference an iterator to IterType

RangeIteratorFunctions<ElemType * , Iter_T , TUnaryPredicate , DefaultDeref< ElemType * , Iter_T > > itunesdb::utils::RangeIterator< ElemType * , Iter_T , TUnaryPredicate , DefaultDeref< ElemType * , Iter_T > >::m_helper [protected, inherited]

Internal implementors of the underlying functions


The documentation for this class was generated from the following file:
Generated on Wed Nov 28 03:04:38 2007 for libqtpod by  doxygen 1.5.0