OpenMS
Loading...
Searching...
No Matches
ConstRefVector< ContainerT > Class Template Reference

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

#include <OpenMS/DATASTRUCTURES/ConstRefVector.h>

Collaboration diagram for ConstRefVector< ContainerT >:
[legend]

Classes

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

Public Types

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

Friends

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

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> >.

std::vector< const ValueType * > vector_
 the internal vector of ValueType pointers
 
size_type capacity_
 the current capacity
 
const ContainerTypebase_container_ptr_
 Pointer to the base container.
 
template<typename ComparatorType >
void sortByComparator (ComparatorType const &comparator=ComparatorType())
 

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:

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();
This vector holds pointer to the elements of another container.
Definition ConstRefVector.h:44
void resize(const size_t new_size)
Definition ExposedVector.h:132
A container for features.
Definition FeatureMap.h:82
Improvement:
Check if we can omit the iterator template arguments (Clemens)

Member Typedef Documentation

◆ const_iterator

template<typename ContainerT >
typedef ConstIterator const_iterator

◆ const_reference

template<typename ContainerT >
typedef ContainerType::const_reference const_reference

◆ const_reverse_iterator

template<typename ContainerT >
typedef ConstReverseIterator const_reverse_iterator

◆ ConstIterator

template<typename ContainerT >
typedef ConstRefVectorConstIterator<const ValueType> ConstIterator

◆ ConstReverseIterator

template<typename ContainerT >
typedef std::reverse_iterator<ConstIterator> ConstReverseIterator

◆ ContainerType

template<typename ContainerT >
typedef ContainerT ContainerType

Type definitions.

Wrapped container type

◆ difference_type

template<typename ContainerT >
typedef ContainerType::difference_type difference_type

◆ Iterator

template<typename ContainerT >
typedef ConstRefVectorIterator<const ValueType> Iterator

◆ iterator

template<typename ContainerT >
typedef Iterator iterator

◆ pointer

template<typename ContainerT >
typedef ContainerType::pointer pointer

◆ reference

template<typename ContainerT >
typedef ContainerType::reference reference

◆ reverse_iterator

template<typename ContainerT >
typedef ReverseIterator reverse_iterator

◆ ReverseIterator

template<typename ContainerT >
typedef std::reverse_iterator<Iterator> ReverseIterator

◆ size_type

template<typename ContainerT >
typedef ContainerType::size_type size_type

◆ value_type

template<typename ContainerT >
typedef ValueType value_type

STL-compliance type definitions.

◆ ValueType

template<typename ContainerT >
typedef ContainerType::value_type ValueType

Constructor & Destructor Documentation

◆ ConstRefVector() [1/6]

template<typename ContainerT >
ConstRefVector ( )
inline

See std::vector documentation.

◆ ConstRefVector() [2/6]

template<typename ContainerT >
ConstRefVector ( size_type  n)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

◆ ConstRefVector() [3/6]

template<typename ContainerT >
ConstRefVector ( size_type  n,
const ValueType element 
)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

◆ ConstRefVector() [4/6]

template<typename ContainerT >
ConstRefVector ( const ConstRefVector< ContainerT > &  p)
inline

◆ ConstRefVector() [5/6]

template<typename ContainerT >
template<class InputIterator >
ConstRefVector ( InputIterator  f,
InputIterator  l 
)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

◆ ConstRefVector() [6/6]

template<typename ContainerT >
ConstRefVector ( ContainerType p)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

◆ ~ConstRefVector()

template<typename ContainerT >
~ConstRefVector ( )
inline

See std::vector documentation.

Member Function Documentation

◆ assign() [1/2]

template<typename ContainerT >
template<class InputIterator >
void assign ( InputIterator  f,
InputIterator  l 
)
inline

◆ assign() [2/2]

template<typename ContainerT >
void assign ( size_type  n,
const ValueType x 
)
inline

◆ back()

template<typename ContainerT >
const_reference back ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::end().

◆ begin() [1/2]

◆ begin() [2/2]

template<typename ContainerT >
ConstIterator begin ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

◆ capacity()

template<typename ContainerT >
size_type capacity ( ) const
inline

◆ clear()

template<typename ContainerT >
void clear ( )
inline

◆ empty()

template<typename ContainerT >
bool empty ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

◆ end() [1/2]

◆ end() [2/2]

template<typename ContainerT >
ConstIterator end ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

◆ erase() [1/2]

template<typename ContainerT >
Iterator erase ( Iterator  first,
Iterator  last 
)
inline

◆ erase() [2/2]

template<typename ContainerT >
Iterator erase ( Iterator  pos)
inline

◆ front()

template<typename ContainerT >
const_reference front ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::begin().

◆ insert() [1/3]

template<typename ContainerT >
Iterator insert ( Iterator  pos,
const ValueType element 
)
inline

◆ insert() [2/3]

template<typename ContainerT >
template<class InputIterator >
void insert ( Iterator  pos,
InputIterator  f,
InputIterator  l 
)
inline

◆ insert() [3/3]

template<typename ContainerT >
void insert ( Iterator  pos,
size_type  n,
const ValueType element 
)
inline

◆ max_size()

template<typename ContainerT >
size_type max_size ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

◆ operator!=()

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

See std::vector documentation.

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

◆ operator<()

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

Comparison of container sizes.

References ConstRefVector< ContainerT >::size().

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

◆ operator<=()

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

◆ operator=()

◆ operator==()

◆ operator>()

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

Comparison of container sizes.

References ConstRefVector< ContainerT >::size().

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

◆ operator>=()

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

◆ operator[]()

template<typename ContainerT >
const_reference operator[] ( size_type  n) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

◆ pop_back()

template<typename ContainerT >
void pop_back ( )
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

◆ push_back()

template<typename ContainerT >
void push_back ( const ValueType x)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

◆ rbegin() [1/2]

template<typename ContainerT >
ReverseIterator rbegin ( )
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::end().

◆ rbegin() [2/2]

template<typename ContainerT >
ConstReverseIterator rbegin ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::end().

◆ rend() [1/2]

template<typename ContainerT >
ReverseIterator rend ( )
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::begin().

◆ rend() [2/2]

template<typename ContainerT >
ConstReverseIterator rend ( ) const
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::begin().

◆ reserve()

template<typename ContainerT >
void reserve ( size_type  n)
inline

◆ resize() [1/2]

template<typename ContainerT >
void resize ( size_type  new_size)
inline

See std::vector documentation.

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

◆ resize() [2/2]

template<typename ContainerT >
void resize ( size_type  new_size,
const ValueType t 
)
inline

See std::vector documentation.

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

◆ size()

◆ sortByComparator()

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

◆ sortByIntensity()

template<typename ContainerT >
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 ConstRefVector< ContainerT >::vector_.

◆ sortByPosition()

template<typename ContainerT >
void sortByPosition ( )
inline

Lexicographically sorts the elements by their position.

References ConstRefVector< ContainerT >::vector_.

◆ swap()

template<typename ContainerT >
void swap ( ConstRefVector< ContainerT > &  array)
inline

See std::vector documentation.

References ConstRefVector< ContainerT >::vector_.

Friends And Related Symbol Documentation

◆ swap

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

See std::vector documentation.

Member Data Documentation

◆ base_container_ptr_

template<typename ContainerT >
const ContainerType* base_container_ptr_
protected

◆ capacity_

◆ vector_