libGimbal 0.2.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gbl::Vector< T > Class Template Reference
Inheritance diagram for gbl::Vector< T >:
Collaboration diagram for gbl::Vector< T >:

Public Types

using VectorType
 
using VectorViewBaseType
 
using ViewType
 
using MoveValues
 
using iterator
 
using const_iterator
 
using difference_type
 
- Public Types inherited from gbl::VectorViewBase< Vector< T >, T >
using VectorViewBaseType
 
using DerivedType
 
using IterableType
 
using IndexableType
 
using value_type
 
using allocator_type
 
using size_type
 
using difference_type
 
using reference
 
using const_reference
 
using pointer
 
using const_pointer
 
using iterator
 
using const_iterator
 
using reverse_iterator
 
using reverse_const_iterator
 
- Public Types inherited from gbl::RandomAccessIterable< CRTP, Index, Value >
using iterator
 
using reverse_iterator
 
using const_iterator
 
using reverse_const_iterator
 

Public Member Functions

const GblArrayList * getVector_ (void) const
 
GblArrayList * getVector_ (void)
 
 Vector (std::nullptr_t, Size allocSize=sizeof(VectorType))
 
 Vector (Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (const T *pInitialData, Size elementCount, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType), Size elementSize=sizeof(T))
 
 Vector (Size count, const T &value=T(), Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (std::initializer_list< T > c, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (type_compatible_container_readable< T > auto &&c, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (const type_compatible_iterator_readable< T > auto &first, const type_compatible_iterator_readable< T > auto &last, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (const VectorType &other, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (VectorView< T > other, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (VectorType &&rhs, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
 Vector (GblArrayList &&rhs, Context *pCtx=nullptr, Size allocSize=sizeof(VectorType))
 
auto take (void)
 
void give (MoveValues moveValues)
 
void reserve (Size count)
 
void resize (Size newSize)
 
void shrink_to_fit (void)
 
void pushBack (T value)
 
void push_back (T value)
 
template<typename... Args>
T & emplace_back (Args &&... args)
 
void pushFront (T value)
 
void push_front (T value)
 
iterator insert (const_iterator position, const T *pValue, Size count)
 
iterator insert (const_iterator position, const T &val)
 
iterator insert (const_iterator position, gimbal::Size size, const T &val)
 
iterator insert (const_iterator position, const type_compatible_iterator_readable< T > auto &first, const type_compatible_iterator_readable< T > auto &last)
 
template<type_compatible_iterator_readable< T > It>
requires contiguous_iterator<It>
iterator insert (const_iterator position, const It &first, const It &last)
 
iterator insert (const_iterator position, const type_compatible_container_readable< T > auto &c)
 
iterator insert (const_iterator position, const type_compatible_contiguous_container_readable< T > auto &c)
 
template<typename... Args>
iterator emplace (const_iterator position, Args &&... args)
 
void popBack (void)
 
void pop_back (void)
 
iterator erase (const_iterator pos)
 
iterator erase (const_iterator first, const_iterator last)
 
void clear (void)
 
void assign (const T *pData, Size elementCount)
 
void assign (gimbal::Size size, const T &value)
 
void assign (const type_compatible_contiguous_container_readable< T > auto &c)
 
void assign (const type_compatible_container_readable< T > auto &c)
 
void assign (const type_compatible_iterator_readable< T > auto &first, const type_compatible_iterator_readable< T > auto &last)
 
template<type_compatible_iterator_readable< T > It>
requires contiguous_iterator<It>
void assign (const It &first, const It &last)
 
const VectorType & operator= (VectorView< T > rhs)
 
const VectorType & operator= (const VectorType &rhs)
 
const VectorType & operator= (VectorType &&rhs)
 
const VectorType & operator= (GblArrayList &&rhs)
 
const VectorType & operator= (const type_compatible_container< T > auto &&c)
 
const VectorType & operator+= (const type_compatible_container_readable< T > auto &view)
 
const VectorType & operator+= (const type_compatible_iterator_readable< T > auto &it)
 
const VectorType & operator+= (const T &value)
 
const VectorType & operator+= (VectorView< T > view)
 
Size capacity (void) const
 
- Public Member Functions inherited from gbl::VectorViewBase< Vector< T >, T >
 operator const GblArrayList * () const
 
const_reference getElement_ (size_type index) const
 
reference getElement_ (size_type index)
 
void setElement_ (size_type index, value_type value)
 
size_t getElementCount_ (void) const
 
bool isEmpty (void) const
 
bool isStack (void) const
 
bool isHeap (void) const
 
std::vector< value_type > toStdVector (void) const
 
Size getStackBytes (void) const
 
Context * getContext (void) const
 
allocator_type get_allocator (void) const
 
Size getSize (void) const
 
Size getSizeBytes (void) const
 
Size size_bytes (void) const
 
Size getCapacity (void) const
 
Size capacity (void) const
 
Size getElementSize (void) const
 
size_type element_size (void) const
 
size_type max_size (void) const
 
const void * getData (void) const
 
constexpr pointer data (void)
 
constexpr const_pointer data (void) const
 
T & front (void) const
 
T & back (void) const
 
 operator const GblArrayList * () const
 
const_reference getElement_ (size_type index) const
 
reference getElement_ (size_type index)
 
void setElement_ (size_type index, value_type value)
 
size_t getElementCount_ (void) const
 
bool isEmpty (void) const
 
bool isStack (void) const
 
bool isHeap (void) const
 
std::vector< value_type > toStdVector (void) const
 
Size getStackBytes (void) const
 
Context * getContext (void) const
 
allocator_type get_allocator (void) const
 
Size getSize (void) const
 
Size getSizeBytes (void) const
 
Size size_bytes (void) const
 
Size getCapacity (void) const
 
Size capacity (void) const
 
Size getElementSize (void) const
 
size_type element_size (void) const
 
size_type max_size (void) const
 
const void * getData (void) const
 
constexpr pointer data (void)
 
constexpr const_pointer data (void) const
 
T & front (void) const
 
T & back (void) const
 
- Public Member Functions inherited from gbl::ReadWriteContiguousIndexable< CRTP, Index, Value, Writable >
void checkBounds (Index index) const
 
Index size (void) const
 
Index length (void) const
 
Index empty (void) const
 
Value at (Index index) const
 
IndexableProxy at (Index index)
 
Value front (Index index) const
 
IndexableProxy front (void)
 
Value back (void) const
 
IndexableProxy back (void)
 
- Public Member Functions inherited from gbl::ReadWriteIndexable< CRTP, Index, Value, Writable >
Value operator[] (Index key) const
 
SubscriptProxy operator[] (Index key)
 
- Public Member Functions inherited from gbl::RandomAccessIterable< CRTP, Index, Value >
iterator begin (void)
 
auto begin (void) const
 
auto rbegin (void)
 
auto rbegin (void) const
 
iterator end (void)
 
auto end (void) const
 
auto rend (void)
 
auto rend (void) const
 
const_iterator cbegin (void) const
 
auto crbegin (void) const
 
const_iterator cend (void) const
 
auto crend (void) const
 

Static Public Member Functions

static MoveValues take (GblArrayList *pVec)
 

Protected Member Functions

void destruct_ (Size startPos, Size count=1)
 
- Protected Member Functions inherited from gbl::VectorViewBase< Vector< T >, T >
decltype(auto) vec_ (void) const
 
decltype(auto) vec_ (void)
 
void * at_ (Size index) const
 
decltype(auto) vec_ (void) const
 
decltype(auto) vec_ (void)
 
void * at_ (Size index) const
 

Additional Inherited Members

- Data Fields inherited from GblArrayList
struct { 
 
   GblContext *   pCtx 
 
   uint8_t *   pData 
 
   size_t   size 
 
   size_t   capacity 
 
   uint16_t   elementSize 
 
   uint16_t   zeroTerminated: 1 
 
   uint16_t   stackCapacity: 15 
 
} private_ 
 

Detailed Description

template<typename T>
class gbl::Vector< T >

Definition at line 262 of file gimbal_vector.hpp.

Member Typedef Documentation

◆ VectorType

template<typename T>
using gbl::Vector< T >::VectorType

Definition at line 277 of file gimbal_vector.hpp.

◆ VectorViewBaseType

template<typename T>
using gbl::Vector< T >::VectorViewBaseType

Definition at line 278 of file gimbal_vector.hpp.

◆ ViewType

template<typename T>
using gbl::Vector< T >::ViewType

Definition at line 279 of file gimbal_vector.hpp.

◆ MoveValues

template<typename T>
using gbl::Vector< T >::MoveValues

Definition at line 280 of file gimbal_vector.hpp.

◆ iterator

template<typename T>
using gbl::Vector< T >::iterator

Definition at line 281 of file gimbal_vector.hpp.

◆ const_iterator

template<typename T>
using gbl::Vector< T >::const_iterator

Definition at line 282 of file gimbal_vector.hpp.

◆ difference_type

template<typename T>
using gbl::Vector< T >::difference_type

Definition at line 283 of file gimbal_vector.hpp.

Constructor & Destructor Documentation

◆ Vector() [1/11]

template<typename T>
gbl::Vector< T >::Vector ( std::nullptr_t ,
Size allocSize = sizeof(VectorType) )
inlineexplicit

Definition at line 296 of file gimbal_vector.hpp.

◆ Vector() [2/11]

template<typename T>
gbl::Vector< T >::Vector ( Context * pCtx = nullptr,
Size allocSize = sizeof(VectorType) )
inlineexplicit

Definition at line 300 of file gimbal_vector.hpp.

300 :
301 Vector(nullptr, 0, nullptr, allocSize) {}

◆ Vector() [3/11]

template<typename T>
gbl::Vector< T >::Vector ( const T * pInitialData,
Size elementCount,
Context * pCtx = nullptr,
Size allocSize = sizeof(VectorType),
Size elementSize = sizeof(T) )
inlineexplicit

Definition at line 304 of file gimbal_vector.hpp.

304 :
305 Vector(nullptr, 0, pCtx, allocSize) {}
306

◆ Vector() [4/11]

template<typename T>
gbl::Vector< T >::Vector ( Size count,
const T & value = T(),
Context * pCtx = nullptr,
Size allocSize = sizeof(VectorType) )
inlineexplicit

Definition at line 309 of file gimbal_vector.hpp.

313 {

◆ Vector() [5/11]

template<typename T>
gbl::Vector< T >::Vector ( std::initializer_list< T > c,
Context * pCtx = nullptr,
Size allocSize = sizeof(VectorType) )
inline

Definition at line 316 of file gimbal_vector.hpp.

320 :
321

◆ Vector() [6/11]

template<typename T>
gbl::Vector< T >::Vector ( type_compatible_container_readable< T > auto && c,
Context * pCtx = nullptr,
Size allocSize = sizeof(VectorType) )
inlineexplicit

Definition at line 324 of file gimbal_vector.hpp.

328 :
329

◆ Vector() [7/11]

template<typename T>
gbl::Vector< T >::Vector ( const type_compatible_iterator_readable< T > auto & first,
const type_compatible_iterator_readable< T > auto & last,
Context * pCtx = nullptr,
Size allocSize = sizeof(VectorType) )
inlineexplicit

Definition at line 331 of file gimbal_vector.hpp.

335 :
336

◆ Vector() [8/11]

template<typename T>
gbl::Vector< T >::Vector ( const VectorType & other,
Context * pCtx = nullptr,
Size allocSize = sizeof(VectorType) )
inline

Definition at line 340 of file gimbal_vector.hpp.

◆ Vector() [9/11]

template<typename T>
gbl::Vector< T >::Vector ( VectorView< T > other,
Context * pCtx = nullptr,
Size allocSize = sizeof(VectorType) )
inline

Definition at line 344 of file gimbal_vector.hpp.

344 :
345 Vector(VectorView(other), pCtx, allocSize) {}

◆ Vector() [10/11]

template<typename T>
gbl::Vector< T >::Vector ( VectorType && rhs,
Context * pCtx = nullptr,
Size allocSize = sizeof(VectorType) )
inline

Definition at line 351 of file gimbal_vector.hpp.

◆ Vector() [11/11]

template<typename T>
gbl::Vector< T >::Vector ( GblArrayList && rhs,
Context * pCtx = nullptr,
Size allocSize = sizeof(VectorType) )
inline

Definition at line 355 of file gimbal_vector.hpp.

355 :
356 Vector(static_cast<GblArrayList&&>(rhs), pCtx, allocSize) {}
357
358 // move constructor - GblArrayList
359 Vector(GblArrayList&& rhs, Context* pCtx=nullptr, Size allocSize=sizeof(VectorType)):

◆ ~Vector()

template<typename T>
gbl::Vector< T >::~Vector ( void )
inline

Definition at line 377 of file gimbal_vector.hpp.

Member Function Documentation

◆ destruct_()

template<typename T>
void gbl::Vector< T >::destruct_ ( Size startPos,
Size count = 1 )
inlineprotected

Definition at line 268 of file gimbal_vector.hpp.

269{
270protected:
271
272 void destruct_(Size startPos, Size count=1) {
273 if constexpr(std::is_destructible_v<T>) {
274 for(Size i = startPos; i < count; ++i) {

◆ getVector_() [1/2]

template<typename T>
const GblArrayList * gbl::Vector< T >::getVector_ ( void ) const
inline

Definition at line 285 of file gimbal_vector.hpp.

◆ getVector_() [2/2]

template<typename T>
GblArrayList * gbl::Vector< T >::getVector_ ( void )
inline

Definition at line 289 of file gimbal_vector.hpp.

289 {
290 return static_cast<const GblArrayList*>(this);
291 }

◆ take() [1/2]

template<typename T>
static MoveValues gbl::Vector< T >::take ( GblArrayList * pVec)
inlinestatic

Definition at line 361 of file gimbal_vector.hpp.

361 {
362 *this = std::move(rhs);
363 }
364
365 static MoveValues take(GblArrayList* pVec) {
366 auto moveValues = MoveValues(nullptr, 0, 0);

◆ take() [2/2]

template<typename T>
auto gbl::Vector< T >::take ( void )
inline

Definition at line 368 of file gimbal_vector.hpp.

◆ give()

template<typename T>
void gbl::Vector< T >::give ( MoveValues moveValues)
inline

Definition at line 372 of file gimbal_vector.hpp.

372 {
373 return take(this);
374 }
375

◆ reserve()

template<typename T>
void gbl::Vector< T >::reserve ( Size count)
inline

Definition at line 385 of file gimbal_vector.hpp.

◆ resize()

template<typename T>
void gbl::Vector< T >::resize ( Size newSize)
inline

Definition at line 389 of file gimbal_vector.hpp.

389 {
391 }
392
393 void resize(Size newSize) {
394 if(newSize < size()) {

◆ shrink_to_fit()

template<typename T>
void gbl::Vector< T >::shrink_to_fit ( void )
inline

Definition at line 396 of file gimbal_vector.hpp.

◆ pushBack()

template<typename T>
void gbl::Vector< T >::pushBack ( T value)
inline

Definition at line 400 of file gimbal_vector.hpp.

◆ push_back()

template<typename T>
void gbl::Vector< T >::push_back ( T value)
inline

Definition at line 404 of file gimbal_vector.hpp.

◆ emplace_back()

template<typename T>
template<typename... Args>
T & gbl::Vector< T >::emplace_back ( Args &&... args)
inline

Definition at line 409 of file gimbal_vector.hpp.

413 {
414 resize(size()+1);

◆ pushFront()

template<typename T>
void gbl::Vector< T >::pushFront ( T value)
inline

Definition at line 416 of file gimbal_vector.hpp.

◆ push_front()

template<typename T>
void gbl::Vector< T >::push_front ( T value)
inline

Definition at line 420 of file gimbal_vector.hpp.

◆ insert() [1/7]

template<typename T>
iterator gbl::Vector< T >::insert ( const_iterator position,
const T * pValue,
Size count )
inline

Definition at line 424 of file gimbal_vector.hpp.

424 {
425 pushFront(std::move(value));
426 }
427
428 iterator insert(const_iterator position, const T* pValue, Size count) {
429 const auto index = std::distance(this->cbegin(), position);

◆ insert() [2/7]

template<typename T>
iterator gbl::Vector< T >::insert ( const_iterator position,
const T & val )
inline

Definition at line 432 of file gimbal_vector.hpp.

◆ insert() [3/7]

template<typename T>
iterator gbl::Vector< T >::insert ( const_iterator position,
gimbal::Size size,
const T & val )
inline

Definition at line 436 of file gimbal_vector.hpp.

436 {
437 return insert(std::move(position), &val, 1);
438 }
439
440 iterator insert(const_iterator position, gimbal::Size size, const T& val) {

◆ insert() [4/7]

template<typename T>
iterator gbl::Vector< T >::insert ( const_iterator position,
const type_compatible_iterator_readable< T > auto & first,
const type_compatible_iterator_readable< T > auto & last )
inline

Definition at line 442 of file gimbal_vector.hpp.

446 {
447 const auto size = std::distance(first, last);

◆ insert() [5/7]

template<typename T>
template<type_compatible_iterator_readable< T > It>
requires contiguous_iterator<It>
iterator gbl::Vector< T >::insert ( const_iterator position,
const It & first,
const It & last )
inline

Definition at line 451 of file gimbal_vector.hpp.

◆ insert() [6/7]

template<typename T>
iterator gbl::Vector< T >::insert ( const_iterator position,
const type_compatible_container_readable< T > auto & c )
inline

Definition at line 455 of file gimbal_vector.hpp.

455 {
456 return insert(std::move(position), &first[0], std::distance(first, last));
457 }

◆ insert() [7/7]

template<typename T>
iterator gbl::Vector< T >::insert ( const_iterator position,
const type_compatible_contiguous_container_readable< T > auto & c )
inline

Definition at line 459 of file gimbal_vector.hpp.

459 {
460 return insert(std::move(position), std::cbegin(c), std::cend(c));
461 }

◆ emplace()

template<typename T>
template<typename... Args>
iterator gbl::Vector< T >::emplace ( const_iterator position,
Args &&... args )
inline

Definition at line 464 of file gimbal_vector.hpp.

468 {
469 const auto index = std::distance(this->cbegin(), position);
470 void* pData = nullptr;
472 pData = GblArrayList_insert(this, index, 1, nullptr);

◆ popBack()

template<typename T>
void gbl::Vector< T >::popBack ( void )
inline

Definition at line 474 of file gimbal_vector.hpp.

◆ pop_back()

template<typename T>
void gbl::Vector< T >::pop_back ( void )
inline

Definition at line 479 of file gimbal_vector.hpp.

◆ erase() [1/2]

template<typename T>
iterator gbl::Vector< T >::erase ( const_iterator pos)
inline

Definition at line 483 of file gimbal_vector.hpp.

483 {
484 popBack();
485 }

◆ erase() [2/2]

template<typename T>
iterator gbl::Vector< T >::erase ( const_iterator first,
const_iterator last )
inline

Definition at line 487 of file gimbal_vector.hpp.

487 {
488 return erase(pos, pos+1);
489 }
490
491 iterator erase(const_iterator first, const_iterator last) {
492 const auto index = std::distance<const_iterator>(this->begin(), first);
493 const auto count = std::distance(first, last);

◆ clear()

template<typename T>
void gbl::Vector< T >::clear ( void )
inline

Definition at line 495 of file gimbal_vector.hpp.

◆ assign() [1/6]

template<typename T>
void gbl::Vector< T >::assign ( const T * pData,
Size elementCount )
inline

Definition at line 500 of file gimbal_vector.hpp.

◆ assign() [2/6]

template<typename T>
void gbl::Vector< T >::assign ( gimbal::Size size,
const T & value )
inline

Definition at line 504 of file gimbal_vector.hpp.

504 {
506 }
507
508 void assign(gimbal::Size size, const T& value) {

◆ assign() [3/6]

template<typename T>
void gbl::Vector< T >::assign ( const type_compatible_contiguous_container_readable< T > auto & c)
inline

Definition at line 510 of file gimbal_vector.hpp.

◆ assign() [4/6]

template<typename T>
void gbl::Vector< T >::assign ( const type_compatible_container_readable< T > auto & c)
inline

Definition at line 514 of file gimbal_vector.hpp.

514 {
515 assign(c.data(), std::size(c));
516 }
517
518 void assign(const type_compatible_container_readable<T> auto& c) {

◆ assign() [5/6]

template<typename T>
void gbl::Vector< T >::assign ( const type_compatible_iterator_readable< T > auto & first,
const type_compatible_iterator_readable< T > auto & last )
inline

Definition at line 520 of file gimbal_vector.hpp.

524 {
525 const auto size = std::distance(first, last);

◆ assign() [6/6]

template<typename T>
template<type_compatible_iterator_readable< T > It>
requires contiguous_iterator<It>
void gbl::Vector< T >::assign ( const It & first,
const It & last )
inline

Definition at line 529 of file gimbal_vector.hpp.

533 {
534
535 const T* pData = &first[0];

◆ operator=() [1/5]

template<typename T>
const VectorType & gbl::Vector< T >::operator= ( VectorView< T > rhs)
inline

Definition at line 537 of file gimbal_vector.hpp.

◆ operator=() [2/5]

template<typename T>
const VectorType & gbl::Vector< T >::operator= ( const VectorType & rhs)
inline

Definition at line 542 of file gimbal_vector.hpp.

◆ operator=() [3/5]

template<typename T>
const VectorType & gbl::Vector< T >::operator= ( VectorType && rhs)
inline

Definition at line 546 of file gimbal_vector.hpp.

546 {
547 return *this = VectorView<T>(rhs);
548 }

◆ operator=() [4/5]

template<typename T>
const VectorType & gbl::Vector< T >::operator= ( GblArrayList && rhs)
inline

Definition at line 550 of file gimbal_vector.hpp.

550 {
551 return *this = static_cast<GblArrayList&&>(rhs);
552 }
553
554 const VectorType& operator=(GblArrayList&& rhs) {
555 VectorView<T> rhsView(rhs); //C++ wrapper "viewing" C object
556
557 if(this->getContext() == rhsView.getContext() && rhsView.isHeap()) {
558 give(take(&rhs));
559 } else {

◆ operator=() [5/5]

template<typename T>
const VectorType & gbl::Vector< T >::operator= ( const type_compatible_container< T > auto && c)
inline

Definition at line 561 of file gimbal_vector.hpp.

565 {
566 // check for supported move semantics!

◆ operator+=() [1/4]

template<typename T>
const VectorType & gbl::Vector< T >::operator+= ( const type_compatible_container_readable< T > auto & view)
inline

Definition at line 569 of file gimbal_vector.hpp.

569 {
570 assign(c);
571 }
572 } else

◆ operator+=() [2/4]

template<typename T>
const VectorType & gbl::Vector< T >::operator+= ( const type_compatible_iterator_readable< T > auto & it)
inline

Definition at line 574 of file gimbal_vector.hpp.

◆ operator+=() [3/4]

template<typename T>
const VectorType & gbl::Vector< T >::operator+= ( const T & value)
inline

Definition at line 579 of file gimbal_vector.hpp.

579 {
580 insert(this->end(), view);
581 return *this;
582 }

◆ operator+=() [4/4]

template<typename T>
const VectorType & gbl::Vector< T >::operator+= ( VectorView< T > view)
inline

Definition at line 584 of file gimbal_vector.hpp.

584 {
585 insert(this->end(), it);
586 return *this;
587 }

◆ capacity()

template<typename T>
Size gbl::VectorViewBase< Vector< T >, T >::capacity ( void ) const
inline

Definition at line 155 of file gimbal_vector.hpp.

155 {
156 return GblArrayList_capacity(vec_());
157 }

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