ITunesDB::FilteredTrackConstIterator< TrackPredicate_T > Struct Template Reference

An Iterator over a sequence of ITunesDBTrack instances. More...

#include <itunesdb.h>

Inheritance diagram for ITunesDB::FilteredTrackConstIterator< TrackPredicate_T >:

itunesdb::utils::SortablePtrVector< ElemType >::FilteredConstIterator< TrackPredicate_T > itunesdb::utils::SortablePtrVector< ElemType >::ContainerVersionAwareIterator< Container_T, Iter_T, TUnaryPredicate > itunesdb::utils::RangeIterator< ElemType *, Iter_T, TUnaryPredicate > List of all members.

Public Member Functions

 FilteredTrackConstIterator (const TrackList &tracklst, const TrackPredicate_T &pred=TrackPredicate_T())
 Creates a new FilteredTrackConstIterator over all ITunesDBTrack instances matching the given predicate.
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

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

Friends

class SortablePtrVector

Detailed Description

template<typename TrackPredicate_T = itunesdb::TrackPredicates::AllTracks>
struct ITunesDB::FilteredTrackConstIterator< TrackPredicate_T >

An Iterator over a sequence of ITunesDBTrack instances.

An Iterator over all ITunesDBTrack instances matching the given predicate, delivering pointers to ITunesDBTrack instances by its next() method


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, inherited]

The base type of this iterator.


Constructor & Destructor Documentation

template<typename TrackPredicate_T = itunesdb::TrackPredicates::AllTracks>
ITunesDB::FilteredTrackConstIterator< TrackPredicate_T >::FilteredTrackConstIterator ( const TrackList tracklst,
const TrackPredicate_T &  pred = TrackPredicate_T() 
) [inline]

Creates a new FilteredTrackConstIterator over all ITunesDBTrack instances matching the given predicate.

Parameters:
container the main TrackList to iterate over
predicate the predicate to match the tracks 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, inherited]

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, inherited]

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, inherited]

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, inherited]

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 struct was generated from the following file:
Generated on Wed Dec 19 00:15:19 2007 for libqtpod by  doxygen 1.5.0