A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SortedVector< T, Compare > Class Template Reference

#include <genesis/utils/containers/sorted_vector.hpp>

Detailed Description

template<class T, class Compare = std::less<T>>
class genesis::utils::SortedVector< T, Compare >

Sorted vector of unique elements.

This class offers a thin wrapper around std::vector which ensures that the stored elements are unique and sorted. It also offers to retrieve the index of a value, see index_of().

Definition at line 53 of file sorted_vector.hpp.

Public Member Functions

 SortedVector ()=default
 
 SortedVector (SortedVector const &)=default
 
 SortedVector (SortedVector &&)=default
 
 SortedVector (std::initializer_list< value_type > il)
 
 ~SortedVector ()=default
 
reference at (size_type index)
 
const_reference at (size_type index) const
 
reference back ()
 
const_reference back () const
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin ()
 
const_iterator cend ()
 
void clear ()
 
bool contains (const_reference value) const
 Return whether a certain value is present in the container. More...
 
bool empty () const
 
iterator end ()
 
const_iterator end () const
 
reference front ()
 
const_reference front () const
 
size_type index_of (const_reference value) const
 Return the index at which a certain value is stored, or size(), if it is not present in the container. More...
 
void insert (const_reference value)
 Insert a value into the container by copying it. More...
 
void insert (value_type &&value)
 Insert a value into the container by moving it. More...
 
template<class InputIterator >
void insert (InputIterator first, InputIterator last)
 Insert values into the container by copying from an InputIterator range. More...
 
SortedVectoroperator= (SortedVector const &)=default
 
SortedVectoroperator= (SortedVector &&)=default
 
reference operator[] (size_type index)
 
const_reference operator[] (size_type index) const
 
void remove (const_reference value)
 Remove a certain value from the container. More...
 
void reserve (size_t n)
 Reserve space in the unterlying vector. More...
 
size_type size () const
 

Public Types

using const_iterator = typename std::vector< value_type >::const_iterator
 
using const_pointer = const value_type *
 
using const_reference = const value_type &
 
using iterator = typename std::vector< value_type >::iterator
 
using pointer = value_type *
 
using reference = value_type &
 
using size_type = size_t
 
using value_compare = Compare
 
using value_type = T
 

Constructor & Destructor Documentation

SortedVector ( )
default
~SortedVector ( )
default
SortedVector ( SortedVector< T, Compare > const &  )
default
SortedVector ( SortedVector< T, Compare > &&  )
default
SortedVector ( std::initializer_list< value_type il)
inline

Definition at line 84 of file sorted_vector.hpp.

Member Function Documentation

reference at ( size_type  index)
inline

Definition at line 184 of file sorted_vector.hpp.

const_reference at ( size_type  index) const
inline

Definition at line 189 of file sorted_vector.hpp.

reference back ( )
inline

Definition at line 204 of file sorted_vector.hpp.

const_reference back ( ) const
inline

Definition at line 209 of file sorted_vector.hpp.

iterator begin ( )
inline

Definition at line 99 of file sorted_vector.hpp.

const_iterator begin ( ) const
inline

Definition at line 104 of file sorted_vector.hpp.

const_iterator cbegin ( )
inline

Definition at line 119 of file sorted_vector.hpp.

const_iterator cend ( )
inline

Definition at line 124 of file sorted_vector.hpp.

void clear ( )
inline

Definition at line 289 of file sorted_vector.hpp.

bool contains ( const_reference  value) const
inline

Return whether a certain value is present in the container.

Definition at line 150 of file sorted_vector.hpp.

bool empty ( ) const
inline

Definition at line 138 of file sorted_vector.hpp.

iterator end ( )
inline

Definition at line 109 of file sorted_vector.hpp.

const_iterator end ( ) const
inline

Definition at line 114 of file sorted_vector.hpp.

reference front ( )
inline

Definition at line 194 of file sorted_vector.hpp.

const_reference front ( ) const
inline

Definition at line 199 of file sorted_vector.hpp.

size_type index_of ( const_reference  value) const
inline

Return the index at which a certain value is stored, or size(), if it is not present in the container.

Definition at line 159 of file sorted_vector.hpp.

void insert ( const_reference  value)
inline

Insert a value into the container by copying it.

If a value comparing equal to the new one is already stored in the container, nothing happens.

Definition at line 223 of file sorted_vector.hpp.

void insert ( value_type &&  value)
inline

Insert a value into the container by moving it.

If a value comparing equal to the new one is already stored in the container, nothing happens.

Definition at line 240 of file sorted_vector.hpp.

void insert ( InputIterator  first,
InputIterator  last 
)
inline

Insert values into the container by copying from an InputIterator range.

The function copies all values in the range [ first, last ) into the container.

Definition at line 257 of file sorted_vector.hpp.

SortedVector& operator= ( SortedVector< T, Compare > const &  )
default
SortedVector& operator= ( SortedVector< T, Compare > &&  )
default
reference operator[] ( size_type  index)
inline

Definition at line 174 of file sorted_vector.hpp.

const_reference operator[] ( size_type  index) const
inline

Definition at line 179 of file sorted_vector.hpp.

void remove ( const_reference  value)
inline

Remove a certain value from the container.

If the value is not stored in the container, nothing happens.

Definition at line 270 of file sorted_vector.hpp.

void reserve ( size_t  n)
inline

Reserve space in the unterlying vector.

Definition at line 284 of file sorted_vector.hpp.

size_type size ( ) const
inline

Definition at line 133 of file sorted_vector.hpp.

Member Typedef Documentation

using const_iterator = typename std::vector< value_type >::const_iterator

Definition at line 69 of file sorted_vector.hpp.

using const_pointer = const value_type*

Definition at line 66 of file sorted_vector.hpp.

using const_reference = const value_type&

Definition at line 64 of file sorted_vector.hpp.

using iterator = typename std::vector< value_type >::iterator

Definition at line 68 of file sorted_vector.hpp.

using pointer = value_type*

Definition at line 65 of file sorted_vector.hpp.

Definition at line 63 of file sorted_vector.hpp.

using size_type = size_t

Definition at line 71 of file sorted_vector.hpp.

using value_compare = Compare

Definition at line 72 of file sorted_vector.hpp.

using value_type = T

Definition at line 61 of file sorted_vector.hpp.


The documentation for this class was generated from the following file: