VPTissue Reference Manual
SimPT_Sim::Container::SegmentedVector< T, N > Class Template Reference

Container that stores objects "almost contiguously" and guarantees that pointers/iterators are not invalidated when the container grows. More...

#include <SegmentedVector.h>

Inheritance diagram for SimPT_Sim::Container::SegmentedVector< T, N >:
Inheritance graph
Collaboration diagram for SimPT_Sim::Container::SegmentedVector< T, N >:
Collaboration graph

Public Types

using const_iterator = SVIterator< T, N >
 
using iterator = SVIterator< T, N, T *, T &, false >
 
using self_type = SegmentedVector< T, N >
 
using size_type = std::size_t
 
using value_type = T
 

Public Member Functions

 SegmentedVector ()
 Construct.
 
 SegmentedVector (const self_type &other)
 Copy constructor.
 
 SegmentedVector (self_type &&other)
 Move constructor.
 
 ~SegmentedVector ()
 Destructor.
 
T & at (std::size_t pos)
 Access specified element with bounds checking.
 
const T & at (std::size_t pos) const
 Access specified element with bounds checking.
 
T & back ()
 Access the last element.
 
const T & back () const
 Access the last element.
 
iterator begin ()
 Returns an iterator to the beginning of the container.
 
const_iterator begin () const
 Returns a const_iterator to the beginning of the container.
 
const_iterator cbegin () const
 Returns a const_iterator to the beginning of the container.
 
const_iterator cend () const
 Returns a const_iterator to the end.
 
void clear ()
 Clears the content.
 
template<class... Args>
T * emplace_back (Args &&...args)
 Constructs element in-place at the end.
 
bool empty () const
 Checks whether container is empty.
 
iterator end ()
 Returns an iterator to the end of the container.
 
const_iterator end () const
 Returns a const_iterator to the end of the container.
 
std::size_t get_block_count () const
 Returns number of currently allocated blocks.
 
std::size_t get_elements_per_block () const
 Returns number of elements block (template parameter 'N').
 
self_typeoperator= (const self_type &other)
 Copy assignment.
 
self_typeoperator= (self_type &&other)
 Move assignment.
 
T & operator[] (size_t pos)
 Access specified element (no bounds checking).
 
const T & operator[] (size_t pos) const
 Access specified element (no bounds checking).
 
void pop_back ()
 Removes the last element.
 
T * push_back (const T &obj)
 Adds element to end.
 
T * push_back (T &&obj)
 Adds element to end.
 
std::size_t size () const
 Returns the number of elements.
 

Friends

class SVIterator< T, N >
 
class SVIterator< T, N, T *, T &, false >
 

Detailed Description

template<typename T, size_t N = 512>
class SimPT_Sim::Container::SegmentedVector< T, N >

Container that stores objects "almost contiguously" and guarantees that pointers/iterators are not invalidated when the container grows.

It combines vector properties (high data locality) with queue properties (can increase capacity without pointer/iterator invalidation). Actually, its implementation is much like a queue but with a limited interface e.g. no insertions. The reason for the SegmentedVector is that one cannot control the block size for std:queue (where it is small) and we need that control to make the block size flexible and rather large.

Template parameters: T type of elements stored in the container N block size i.e. number of elements per block

Definition at line 51 of file SegmentedVector.h.


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