MeshLib C++ Docs
Loading...
Searching...
No Matches
MR::Vector< T, I > Class Template Reference

std::vector<T>-like container that requires specific indexing type, More...

#include <MRVector.h>

Public Types

using value_type = typename std::vector<T>::value_type
 
using reference = typename std::vector<T>::reference
 
using const_reference = typename std::vector<T>::const_reference
 
using iterator = typename std::vector<T>::iterator
 
using const_iterator = typename std::vector<T>::const_iterator
 

Public Member Functions

 Vector ()=default
 
 Vector (size_t size)
 
 Vector (size_t size, const T &val)
 
 Vector (std::vector< T > &&vec)
 
template<class InputIt >
 Vector (InputIt first, InputIt last)
 
 Vector (std::initializer_list< T > init)
 
bool operator== (const Vector &b) const
 
bool operator!= (const Vector &b) const
 
void clear ()
 
bool empty () const
 
std::size_t size () const
 
void resize (size_t newSize)
 
void resize (size_t newSize, const T &t)
 
void resizeNoInit (size_t targetSize)
 
std::size_t capacity () const
 
void reserve (size_t capacity)
 
const_reference operator[] (I i) const
 
reference operator[] (I i)
 
void resizeWithReserve (size_t newSize)
 doubles reserved memory until resize(newSize) can be done without reallocation
 
void resizeWithReserve (size_t newSize, const T &value)
 doubles reserved memory until resize(newSize) can be done without reallocation
 
void autoResizeSet (I pos, size_t len, T val)
 sets elements [pos, pos+len) to given value, adjusting the size of the vector to include new elements
 
void autoResizeSet (I i, T val)
 
reference autoResizeAt (I i)
 this accessor automatically adjusts the size of the vector
 
void push_back (const T &t)
 
void push_back (T &&t)
 
void pop_back ()
 
template<typename... Args>
T & emplace_back (Args &&... args)
 
const_reference front () const
 
reference front ()
 
const_reference back () const
 
reference back ()
 
beginId () const
 returns the identifier of the first element
 
backId () const
 returns the identifier of the back() element
 
endId () const
 returns backId() + 1
 
T * data ()
 
const T * data () const
 
void swap (Vector &b)
 
size_t heapBytes () const
 returns the amount of memory this object occupies on heap
 

Public Attributes

std::vector< T > vec_
 the user can directly manipulate the vector, anyway she cannot break anything
 

Detailed Description

template<typename T, typename I>
class MR::Vector< T, I >

std::vector<T>-like container that requires specific indexing type,

Template Parameters
Ttype of stored elements
Itype of index (shall be convertible to size_t)

Member Typedef Documentation

◆ const_iterator

template<typename T , typename I >
using MR::Vector< T, I >::const_iterator = typename std::vector<T>::const_iterator

◆ const_reference

template<typename T , typename I >
using MR::Vector< T, I >::const_reference = typename std::vector<T>::const_reference

◆ iterator

template<typename T , typename I >
using MR::Vector< T, I >::iterator = typename std::vector<T>::iterator

◆ reference

template<typename T , typename I >
using MR::Vector< T, I >::reference = typename std::vector<T>::reference

◆ value_type

template<typename T , typename I >
using MR::Vector< T, I >::value_type = typename std::vector<T>::value_type

Constructor & Destructor Documentation

◆ Vector() [1/6]

template<typename T , typename I >
MR::Vector< T, I >::Vector ( )
default

◆ Vector() [2/6]

template<typename T , typename I >
MR::Vector< T, I >::Vector ( size_t size)
inlineexplicit

◆ Vector() [3/6]

template<typename T , typename I >
MR::Vector< T, I >::Vector ( size_t size,
const T & val )
inlineexplicit

◆ Vector() [4/6]

template<typename T , typename I >
MR::Vector< T, I >::Vector ( std::vector< T > && vec)
inline

◆ Vector() [5/6]

template<typename T , typename I >
template<class InputIt >
MR::Vector< T, I >::Vector ( InputIt first,
InputIt last )
inline

◆ Vector() [6/6]

template<typename T , typename I >
MR::Vector< T, I >::Vector ( std::initializer_list< T > init)
inline

Member Function Documentation

◆ autoResizeAt()

template<typename T , typename I >
reference MR::Vector< T, I >::autoResizeAt ( I i)
inlinenodiscard

this accessor automatically adjusts the size of the vector

◆ autoResizeSet() [1/2]

template<typename T , typename I >
void MR::Vector< T, I >::autoResizeSet ( I i,
T val )
inline

◆ autoResizeSet() [2/2]

template<typename T , typename I >
void MR::Vector< T, I >::autoResizeSet ( I pos,
size_t len,
T val )
inline

sets elements [pos, pos+len) to given value, adjusting the size of the vector to include new elements

◆ back() [1/2]

template<typename T , typename I >
reference MR::Vector< T, I >::back ( )
inlinenodiscard

◆ back() [2/2]

template<typename T , typename I >
const_reference MR::Vector< T, I >::back ( ) const
inlinenodiscard

◆ backId()

template<typename T , typename I >
I MR::Vector< T, I >::backId ( ) const
inlinenodiscard

returns the identifier of the back() element

◆ beginId()

template<typename T , typename I >
I MR::Vector< T, I >::beginId ( ) const
inlinenodiscard

returns the identifier of the first element

◆ capacity()

template<typename T , typename I >
std::size_t MR::Vector< T, I >::capacity ( ) const
inlinenodiscard

◆ clear()

template<typename T , typename I >
void MR::Vector< T, I >::clear ( )
inline

◆ data() [1/2]

template<typename T , typename I >
T * MR::Vector< T, I >::data ( )
inlinenodiscard

◆ data() [2/2]

template<typename T , typename I >
const T * MR::Vector< T, I >::data ( ) const
inlinenodiscard

◆ emplace_back()

template<typename T , typename I >
template<typename... Args>
T & MR::Vector< T, I >::emplace_back ( Args &&... args)
inline

◆ empty()

template<typename T , typename I >
bool MR::Vector< T, I >::empty ( ) const
inlinenodiscard

◆ endId()

template<typename T , typename I >
I MR::Vector< T, I >::endId ( ) const
inlinenodiscard

returns backId() + 1

◆ front() [1/2]

template<typename T , typename I >
reference MR::Vector< T, I >::front ( )
inlinenodiscard

◆ front() [2/2]

template<typename T , typename I >
const_reference MR::Vector< T, I >::front ( ) const
inlinenodiscard

◆ heapBytes()

template<typename T , typename I >
size_t MR::Vector< T, I >::heapBytes ( ) const
inlinenodiscard

returns the amount of memory this object occupies on heap

◆ operator!=()

template<typename T , typename I >
bool MR::Vector< T, I >::operator!= ( const Vector< T, I > & b) const
inlinenodiscard

◆ operator==()

template<typename T , typename I >
bool MR::Vector< T, I >::operator== ( const Vector< T, I > & b) const
inlinenodiscard

◆ operator[]() [1/2]

template<typename T , typename I >
reference MR::Vector< T, I >::operator[] ( I i)
inlinenodiscard

◆ operator[]() [2/2]

template<typename T , typename I >
const_reference MR::Vector< T, I >::operator[] ( I i) const
inlinenodiscard

◆ pop_back()

template<typename T , typename I >
void MR::Vector< T, I >::pop_back ( )
inline

◆ push_back() [1/2]

template<typename T , typename I >
void MR::Vector< T, I >::push_back ( const T & t)
inline

◆ push_back() [2/2]

template<typename T , typename I >
void MR::Vector< T, I >::push_back ( T && t)
inline

◆ reserve()

template<typename T , typename I >
void MR::Vector< T, I >::reserve ( size_t capacity)
inline

◆ resize() [1/2]

template<typename T , typename I >
void MR::Vector< T, I >::resize ( size_t newSize)
inline

◆ resize() [2/2]

template<typename T , typename I >
void MR::Vector< T, I >::resize ( size_t newSize,
const T & t )
inline

◆ resizeNoInit()

template<typename T , typename I >
void MR::Vector< T, I >::resizeNoInit ( size_t targetSize)
inline

◆ resizeWithReserve() [1/2]

template<typename T , typename I >
void MR::Vector< T, I >::resizeWithReserve ( size_t newSize)
inline

doubles reserved memory until resize(newSize) can be done without reallocation

◆ resizeWithReserve() [2/2]

template<typename T , typename I >
void MR::Vector< T, I >::resizeWithReserve ( size_t newSize,
const T & value )
inline

doubles reserved memory until resize(newSize) can be done without reallocation

◆ size()

template<typename T , typename I >
std::size_t MR::Vector< T, I >::size ( ) const
inlinenodiscard

◆ swap()

template<typename T , typename I >
void MR::Vector< T, I >::swap ( Vector< T, I > & b)
inline

Member Data Documentation

◆ vec_

template<typename T , typename I >
std::vector<T> MR::Vector< T, I >::vec_

the user can directly manipulate the vector, anyway she cannot break anything


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