itunesdb::utils::SortablePtrVector< ElemType > Class Template Reference

#include <utils.h>

List of all members.

Public Types

typedef Comparator< ElemType > SortableVectorElemComparator
 Comparator Type definition.
typedef QTPOD_SHARED_PTR_IMPL_DEF<
SortableVectorElemComparator
ComparatorPtr
 Shared Pointer type managing the pointer to the comparator.
typedef FilteredIterator Iterator
typedef FilteredConstIterator ConstIterator

Public Member Functions

 SortablePtrVector (bool deleteElements=false)
template<typename IterT>
 SortablePtrVector (IterT elements, bool deleteElements=false)
 Creates a sortable vector storing pointers to its elements and fills in the objects returned by the given iterator.
void setComparator (SortableVectorElemComparator *comparator)
 Sets the comparator for this container to by used by sort() and inSort().
void setComparator (const ComparatorPtr &comparator)
 Sets the comparator for this container to by used by sort() and inSort().
const ComparatorPtrgetComparator () const
 Returns the currently used comparator for sorting.
void sort ()
 Sorts the containers element using the comparator set by setComparator().
void randomize ()
 Randomizes the order of the elements.
unsigned int inSort (ElemType *item)
 Inserts the given element accordingly to the comparator set by setComparator().
template<typename IterT>
void addAll (IterT elemIter)
 Adds all elements delivered by the given Iterator.
bool remove (unsigned int pos)
 Removes the element at the given position from the container.
unsigned int count () const
 Returns the number of elements,.
bool isEmpty () const
 Returns true if the number of elements is zero meaning the container is empty, false otherwise.
Iterator iterator ()
 Returns a SortablePtrVector::Iterator over all elements of this Container.
ConstIterator iterator () const
 Returns a SortablePtrVector::ConstIterator over all elements of this Container.
ConstIterator const_iterator () const
 Returns a SortablePtrVector::ConstIterator over all elements of this Container.
template<typename TUnaryPredicate>
FilteredIterator< TUnaryPredicate > filteredElements (const TUnaryPredicate &pred)
 Returns a FilteredIterator over those elements matching the given predicate.
template<typename TUnaryPredicate>
FilteredConstIterator< TUnaryPredicate > filteredElements (const TUnaryPredicate &pred) const
 Returns a FilteredConstIterator over those elements matching the given predicate.
void append (ElemType *item)
 Appends the given element at the end of the container disregarding any comparator.
ElemType * operator[] (unsigned int pos) const
 An operator to access the element at the given position.
ElemType *& operator[] (unsigned int pos)
 An operator to access the element at the given position.
ElemType * last () const
 Returns a pointer to the last element.
void clear ()
 Removes all elements.

Classes

class  ContainerVersionAwareIterator
struct  FilteredConstIterator
class  FilteredIterator
struct  FindFirstNotLessThan
struct  SmallerBinaryPredicate


Detailed Description

template<class ElemType>
class itunesdb::utils::SortablePtrVector< ElemType >

A Class implementing a sortable Vector storing pointers to the given Type


Member Typedef Documentation

template<class ElemType>
typedef Comparator<ElemType> itunesdb::utils::SortablePtrVector< ElemType >::SortableVectorElemComparator

Comparator Type definition.

template<class ElemType>
typedef QTPOD_SHARED_PTR_IMPL_DEF< SortableVectorElemComparator > itunesdb::utils::SortablePtrVector< ElemType >::ComparatorPtr

Shared Pointer type managing the pointer to the comparator.

template<class ElemType>
typedef FilteredIterator itunesdb::utils::SortablePtrVector< ElemType >::Iterator

An unfiltered Iterator over all elements of this container.

template<class ElemType>
typedef FilteredConstIterator itunesdb::utils::SortablePtrVector< ElemType >::ConstIterator

A const Iterator over all elements of this container.

See also:
RangeIterator for more details


Constructor & Destructor Documentation

template<class ElemType>
itunesdb::utils::SortablePtrVector< ElemType >::SortablePtrVector ( bool  deleteElements = false  )  [inline]

Creates a sortable vector storing pointers to its elements.

Parameters:
deleteElements if true the container will delete elements being removed from this container.

template<class ElemType>
template<typename IterT>
itunesdb::utils::SortablePtrVector< ElemType >::SortablePtrVector ( IterT  elements,
bool  deleteElements = false 
) [inline]

Creates a sortable vector storing pointers to its elements and fills in the objects returned by the given iterator.

Parameters:
elements the elements to be filled in to the container
deleteElements if true the container will delete elements being removed from this container.


Member Function Documentation

template<class ElemType>
void itunesdb::utils::SortablePtrVector< ElemType >::setComparator ( SortableVectorElemComparator comparator  )  [inline]

Sets the comparator for this container to by used by sort() and inSort().

Parameters:
comparator the comparator to be set. The pointer is owned by the container and will be deleted if a new comparator is set.

template<class ElemType>
void itunesdb::utils::SortablePtrVector< ElemType >::setComparator ( const ComparatorPtr comparator  )  [inline]

Sets the comparator for this container to by used by sort() and inSort().

Parameters:
comparator the comparator to be set. The comparators lifecycle is managed by the ComparatorPtr.

template<class ElemType>
const ComparatorPtr& itunesdb::utils::SortablePtrVector< ElemType >::getComparator (  )  const [inline]

Returns the currently used comparator for sorting.

Returns:
the currently used comparator for sorting.

template<class ElemType>
void itunesdb::utils::SortablePtrVector< ElemType >::sort (  )  [inline]

Sorts the containers element using the comparator set by setComparator().

If no comparator has been set the order is kept unchanged.

template<class ElemType>
void itunesdb::utils::SortablePtrVector< ElemType >::randomize (  )  [inline]

Randomizes the order of the elements.

template<class ElemType>
unsigned int itunesdb::utils::SortablePtrVector< ElemType >::inSort ( ElemType *  item  )  [inline]

Inserts the given element accordingly to the comparator set by setComparator().

If no comparator has been set the element will be appended at the end.

Parameters:
item the element to be inserted
Returns:
the position/index of the item in this vector.

template<class ElemType>
template<typename IterT>
void itunesdb::utils::SortablePtrVector< ElemType >::addAll ( IterT  elemIter  )  [inline]

Adds all elements delivered by the given Iterator.

template<class ElemType>
bool itunesdb::utils::SortablePtrVector< ElemType >::remove ( unsigned int  pos  )  [inline]

Removes the element at the given position from the container.

If the container was created with deleteElements set to true the element will be deleted.

Parameters:
pos the position of the element to be removed.
Returns:
true if the given position was valid accordingly to the number of elements.

template<class ElemType>
unsigned int itunesdb::utils::SortablePtrVector< ElemType >::count (  )  const [inline]

Returns the number of elements,.

Returns:
the number of elements,

template<class ElemType>
bool itunesdb::utils::SortablePtrVector< ElemType >::isEmpty (  )  const [inline]

Returns true if the number of elements is zero meaning the container is empty, false otherwise.

Returns:
true if the container is empty.

template<class ElemType>
Iterator itunesdb::utils::SortablePtrVector< ElemType >::iterator (  )  [inline]

Returns a SortablePtrVector::Iterator over all elements of this Container.

Returns:
a SortablePtrVector::Iterator over all elements of this Container

template<class ElemType>
ConstIterator itunesdb::utils::SortablePtrVector< ElemType >::iterator (  )  const [inline]

Returns a SortablePtrVector::ConstIterator over all elements of this Container.

Returns:
a SortablePtrVector::ConstIterator over all elements of this Container

template<class ElemType>
ConstIterator itunesdb::utils::SortablePtrVector< ElemType >::const_iterator (  )  const [inline]

Returns a SortablePtrVector::ConstIterator over all elements of this Container.

Returns:
a SortablePtrVector::ConstIterator over all elements of this Container

template<class ElemType>
template<typename TUnaryPredicate>
FilteredIterator<TUnaryPredicate> itunesdb::utils::SortablePtrVector< ElemType >::filteredElements ( const TUnaryPredicate &  pred  )  [inline]

Returns a FilteredIterator over those elements matching the given predicate.

Parameters:
pred the predicate used for filtering
Returns:
a filtered Iterator over the elements of this container.

template<class ElemType>
template<typename TUnaryPredicate>
FilteredConstIterator<TUnaryPredicate> itunesdb::utils::SortablePtrVector< ElemType >::filteredElements ( const TUnaryPredicate &  pred  )  const [inline]

Returns a FilteredConstIterator over those elements matching the given predicate.

Parameters:
pred the predicate used for filtering
Returns:
a filtered const Iterator over the elements of this container.

template<class ElemType>
void itunesdb::utils::SortablePtrVector< ElemType >::append ( ElemType *  item  )  [inline]

Appends the given element at the end of the container disregarding any comparator.

Parameters:
item the element to be appended.

template<class ElemType>
ElemType* itunesdb::utils::SortablePtrVector< ElemType >::operator[] ( unsigned int  pos  )  const [inline]

An operator to access the element at the given position.

Parameters:
pos the position of the element to be returned
Returns:
a pointer to the element at the given position

template<class ElemType>
ElemType*& itunesdb::utils::SortablePtrVector< ElemType >::operator[] ( unsigned int  pos  )  [inline]

An operator to access the element at the given position.

Parameters:
pos the position of the element to be returned
Returns:
a reference to the pointer at the given position

template<class ElemType>
ElemType* itunesdb::utils::SortablePtrVector< ElemType >::last (  )  const [inline]

Returns a pointer to the last element.

Returns:
a pointer to the last element.

template<class ElemType>
void itunesdb::utils::SortablePtrVector< ElemType >::clear (  )  [inline]

Removes all elements.


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