Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Classes | Public Member Functions | Protected Attributes | Friends | List of all members
ConstRefVector< ContainerT > Class Template Reference

This vector holds pointer to the elements of another container. More...

#include <OpenMS/DATASTRUCTURES/ConstRefVector.h>

Classes

class  ConstRefVectorConstIterator
 ConstIterator for the ConstRefVector. More...
 
class  ConstRefVectorIterator
 Mutable iterator for the ConstRefVector. More...
 

Public Types

typedef ContainerT ContainerType
 Type definitions. More...
 
typedef ContainerType::value_type ValueType
 
typedef ConstRefVectorIterator< const ValueTypeIterator
 
typedef ConstRefVectorConstIterator< const ValueTypeConstIterator
 
typedef std::reverse_iterator< IteratorReverseIterator
 
typedef std::reverse_iterator< ConstIteratorConstReverseIterator
 
typedef ValueType value_type
 STL-compliance type definitions. More...
 
typedef ContainerType::size_type size_type
 
typedef ContainerType::difference_type difference_type
 
typedef ContainerType::reference reference
 
typedef ContainerType::const_reference const_reference
 
typedef ContainerType::pointer pointer
 
typedef Iterator iterator
 
typedef ConstIterator const_iterator
 
typedef ReverseIterator reverse_iterator
 
typedef ConstReverseIterator const_reverse_iterator
 

Public Member Functions

void push_back (const ValueType &x)
 See std::vector documentation. More...
 
void pop_back ()
 See std::vector documentation. More...
 
size_type size () const
 See std::vector documentation. More...
 
size_type capacity () const
 See std::vector documentation. More...
 
void reserve (size_type n)
 See std::vector documentation. More...
 
size_type max_size () const
 See std::vector documentation. More...
 
Iterator begin ()
 See std::vector documentation. More...
 
Iterator end ()
 See std::vector documentation. More...
 
ConstIterator begin () const
 See std::vector documentation. More...
 
ConstIterator end () const
 See std::vector documentation. More...
 
ReverseIterator rbegin ()
 See std::vector documentation. More...
 
ReverseIterator rend ()
 See std::vector documentation. More...
 
ConstReverseIterator rbegin () const
 See std::vector documentation. More...
 
ConstReverseIterator rend () const
 See std::vector documentation. More...
 
void resize (size_type new_size)
 See std::vector documentation. More...
 
void resize (size_type new_size, const ValueType &t)
 See std::vector documentation. More...
 
const_reference front () const
 See std::vector documentation. More...
 
const_reference back () const
 See std::vector documentation. More...
 
void clear ()
 See std::vector documentation. More...
 
bool empty () const
 See std::vector documentation. More...
 
const_reference operator[] (size_type n) const
 See std::vector documentation. More...
 
bool operator== (const ConstRefVector &array) const
 See std::vector documentation. More...
 
bool operator!= (const ConstRefVector &array) const
 See std::vector documentation. More...
 
bool operator< (const ConstRefVector &array) const
 Comparison of container sizes. More...
 
bool operator> (const ConstRefVector &array) const
 Comparison of container sizes. More...
 
bool operator<= (const ConstRefVector &array) const
 Comparison of container sizes. More...
 
bool operator>= (const ConstRefVector &array) const
 Comparison of container sizes. More...
 
void swap (ConstRefVector &array)
 See std::vector documentation. More...
 
Iterator insert (Iterator pos, const ValueType &element)
 See std::vector documentation. More...
 
void insert (Iterator pos, size_type n, const ValueType &element)
 See std::vector documentation. More...
 
template<class InputIterator >
void insert (Iterator pos, InputIterator f, InputIterator l)
 See std::vector documentation. More...
 
Iterator erase (Iterator pos)
 See std::vector documentation. More...
 
Iterator erase (Iterator first, Iterator last)
 See std::vector documentation. More...
 
ConstRefVectoroperator= (const ConstRefVector &rhs)
 See std::vector documentation. More...
 
template<class InputIterator >
void assign (InputIterator f, InputIterator l)
 See std::vector documentation. More...
 
void assign (size_type n, const ValueType &x)
 See std::vector documentation. More...
 
Constructors and Destructor
 ConstRefVector ()
 See std::vector documentation. More...
 
 ConstRefVector (size_type n)
 See std::vector documentation. More...
 
 ConstRefVector (size_type n, const ValueType &element)
 See std::vector documentation. More...
 
 ConstRefVector (const ConstRefVector &p)
 See std::vector documentation. More...
 
template<class InputIterator >
 ConstRefVector (InputIterator f, InputIterator l)
 See std::vector documentation. More...
 
 ConstRefVector (ContainerType &p)
 See std::vector documentation. More...
 
 ~ConstRefVector ()
 See std::vector documentation. More...
 
void sortByIntensity (bool reverse=false)
 Sorting. More...
 
void sortByPosition ()
 Lexicographically sorts the elements by their position. More...
 
Generic sorting function templates.

Any element comparator can be given as template argument. You can also give the comparator as an argument to the function template (this is useful if the comparator is not default constructed, but keep in mind that STL copies comparators a lot).

Thus your can e.g. write elements.sortByComparator < DFeature<1>::IntensityLess > (), if elements have type ConstRefVector < 1, DFeature <1> >.

template<typename ComparatorType >
void sortByComparator (ComparatorType const &comparator=ComparatorType())
 

Protected Attributes

std::vector< const ValueType * > vector_
 the internal vector of ValueType pointers More...
 
size_type capacity_
 the current capacity More...
 
const ContainerTypebase_container_ptr_
 Pointer to the base container. More...
 

Friends

void swap (ConstRefVector &a1, ConstRefVector &a2)
 See std::vector documentation. More...
 

Detailed Description

template<typename ContainerT>
class OpenMS::ConstRefVector< ContainerT >

This vector holds pointer to the elements of another container.

If you for example want to sort the elements of a constant container, you would have to copy the whole container.
To avoid copy actions this class only holds pointer to the constant elements of a container.
You can insert new elements, but it is not possible to change existing ones.

The following code demonstrates the use of this class:

FeatureMap<> map;
map.resize(10); //...fill map with data
//Create pointer vector to the map
ConstRefVector<FeatureMap<> > ref_vector(map);
//Sort the pointer vector without changing the original data
ref_vector.sortByIntensity();
Improvement:
Check if we can omit the iterator template arguments (Clemens)

Member Typedef Documentation

typedef ContainerType::const_reference const_reference
typedef std::reverse_iterator<ConstIterator> ConstReverseIterator
typedef ContainerT ContainerType

Type definitions.

Wrapped container type

typedef ContainerType::difference_type difference_type
typedef Iterator iterator
typedef ContainerType::pointer pointer
typedef ContainerType::reference reference
typedef std::reverse_iterator<Iterator> ReverseIterator
typedef ContainerType::size_type size_type

STL-compliance type definitions.

typedef ContainerType::value_type ValueType

Constructor & Destructor Documentation

ConstRefVector ( )
inline

See std::vector documentation.

ConstRefVector ( size_type  n)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

ConstRefVector ( size_type  n,
const ValueType element 
)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

ConstRefVector ( const ConstRefVector< ContainerT > &  p)
inline
ConstRefVector ( InputIterator  f,
InputIterator  l 
)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

ConstRefVector ( ContainerType p)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

~ConstRefVector ( )
inline

See std::vector documentation.

Member Function Documentation

void assign ( InputIterator  f,
InputIterator  l 
)
inline
void assign ( size_type  n,
const ValueType x 
)
inline
const_reference back ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::end().

Iterator begin ( )
inline
ConstIterator begin ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

size_type capacity ( ) const
inline
void clear ( )
inline
bool empty ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

Iterator end ( )
inline
ConstIterator end ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

Iterator erase ( Iterator  pos)
inline
Iterator erase ( Iterator  first,
Iterator  last 
)
inline
const_reference front ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::begin().

Iterator insert ( Iterator  pos,
const ValueType element 
)
inline
void insert ( Iterator  pos,
size_type  n,
const ValueType element 
)
inline
void insert ( Iterator  pos,
InputIterator  f,
InputIterator  l 
)
inline
size_type max_size ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

bool operator!= ( const ConstRefVector< ContainerT > &  array) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::operator==().

bool operator< ( const ConstRefVector< ContainerT > &  array) const
inline

Comparison of container sizes.

References ConstRefVector< ContainerT >::size().

Referenced by ConstRefVector< ContainerT >::operator<=().

bool operator<= ( const ConstRefVector< ContainerT > &  array) const
inline
ConstRefVector& operator= ( const ConstRefVector< ContainerT > &  rhs)
inline
bool operator== ( const ConstRefVector< ContainerT > &  array) const
inline
bool operator> ( const ConstRefVector< ContainerT > &  array) const
inline

Comparison of container sizes.

References ConstRefVector< ContainerT >::size().

Referenced by ConstRefVector< ContainerT >::operator>=().

bool operator>= ( const ConstRefVector< ContainerT > &  array) const
inline
const_reference operator[] ( size_type  n) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

void pop_back ( )
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

void push_back ( const ValueType x)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

ReverseIterator rbegin ( )
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::end().

ConstReverseIterator rbegin ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::end().

ReverseIterator rend ( )
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::begin().

ConstReverseIterator rend ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::begin().

void reserve ( size_type  n)
inline
void resize ( size_type  new_size)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::capacity_, and ConstRefVector< ContainerT >::vector_.

void resize ( size_type  new_size,
const ValueType t 
)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::capacity_, and ConstRefVector< ContainerT >::vector_.

size_type size ( ) const
inline
void sortByComparator ( ComparatorType const &  comparator = ComparatorType())
inline
void sortByIntensity ( bool  reverse = false)
inline

Sorting.

These simplified sorting methods are supported for convenience.

Note
To use these methods, the ValueType must provide an interface similar to Peak1D or Peak2D.Sorts the elements by intensity

References OpenMS::pointerComparator(), OpenMS::reverseComparator(), and ConstRefVector< ContainerT >::vector_.

Referenced by IsotopeWaveletTransform< PeakType >::identifyCharge().

void sortByPosition ( )
inline

Lexicographically sorts the elements by their position.

References OpenMS::pointerComparator(), and ConstRefVector< ContainerT >::vector_.

void swap ( ConstRefVector< ContainerT > &  array)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

Friends And Related Function Documentation

void swap ( ConstRefVector< ContainerT > &  a1,
ConstRefVector< ContainerT > &  a2 
)
friend

See std::vector documentation.

Member Data Documentation

const ContainerType* base_container_ptr_
protected
size_type capacity_
protected
std::vector<const ValueType*> vector_
protected

OpenMS / TOPP release 2.0.0 Documentation generated on Thu Aug 20 2015 01:44:33 using doxygen 1.8.9.1