Loading...
Searching...
No Matches
PstVector.h
Go to the documentation of this file.
1// Copyright PS-Tech B.V. All Rights Reserved.
2
3#pragma once
4
5#include "PstBase.h"
6
7#include <cstddef>
8
9 namespace PSTech
10{
11 namespace Utils
12{
28 template<typename T>
29 class PST_EXPORT PstVector
30 {
31 public:
32 typedef T value_type;
33 typedef size_t size_type;
34 typedef T* pointer;
35 typedef const T* const_pointer;
36 typedef T& reference;
37 typedef const T& const_reference;
38 typedef T* iterator;
39 typedef const T* const_iterator;
40
42 PstVector();
43
45 explicit PstVector(size_type size);
46
48 PstVector(size_type size, const_reference data);
49
51 PstVector(const PstVector& vector);
52
54 PstVector(PstVector&& vector) noexcept;
55
57 ~PstVector();
58
60 PstVector& operator=(const PstVector& vector);
61
63 PstVector& operator=(PstVector&& vector) noexcept;
64
66 void swap(PstVector& vector) noexcept;
67
73 size_type size() const;
74
80 size_type capacity() const;
81
83 bool empty() const;
84
91 void reserve(size_type size);
92
98 void resize(size_type size);
99
105 void resize(size_type size, const_reference data);
106
111 void clear();
112
117 void assign(size_type count, const_reference data);
118
123 void push_back(const_reference data);
124
129 void push_back(T&& data);
130
134 void pop_back();
135
141 const_reference at(size_type index) const;
142
148 reference at(size_type index);
149
151 const_reference front() const;
152
154 reference front();
155
157 const_reference back() const;
158
160 reference back();
161
163 const_iterator cbegin() const;
164
166 const_iterator begin() const;
167
169 iterator begin();
170
172 const_iterator cend() const;
173
175 const_iterator end() const;
176
178 iterator end();
179
181 const_reference operator [] (size_type index) const;
182
184 reference operator [] (size_type index);
185
186 private:
188 class Allocator
189 {
190 public:
192 typename PstVector<T>::pointer allocate(typename PstVector<T>::size_type num);
193
195 void construct(typename PstVector<T>::pointer p);
196
198 template<class... A>
199 void construct(typename PstVector<T>::pointer p, A&... arg);
200
202 void construct(typename PstVector<T>::pointer p, T&& data);
203
204 /* Destroy elements of initialized storage p */
205 void destroy(typename PstVector<T>::pointer p);
206
207 /* Deallocate storage p of deleted elements */
208 void deallocate(typename PstVector<T>::pointer p);
209 };
210
211 size_type m_size;
212 size_type m_allocated;
213 pointer m_array;
214 Allocator m_allocator;
215
216 void resize_internal(size_type size, const_pointer data);
217
218 void check_bounds(size_type index) const;
219 };
220}
221}
PstBase.h
PST_EXPORT
#define PST_EXPORT
Definition PstBase.h:12
PSTech::Utils::PstVector::Allocator
Definition PstVector.h:189
PSTech::Utils::PstVector::Allocator::construct
void construct(typename PstVector< T >::pointer p, T &&data)
PSTech::Utils::PstVector::Allocator::construct
void construct(typename PstVector< T >::pointer p, A &... arg)
PSTech::Utils::PstVector::Allocator::construct
void construct(typename PstVector< T >::pointer p)
PSTech::Utils::PstVector::Allocator::destroy
void destroy(typename PstVector< T >::pointer p)
PSTech::Utils::PstVector::Allocator::allocate
PstVector< T >::pointer allocate(typename PstVector< T >::size_type num)
PSTech::Utils::PstVector::Allocator::deallocate
void deallocate(typename PstVector< T >::pointer p)
PSTech::Utils::PstVector::pop_back
void pop_back()
PSTech::Utils::PstVector::front
const_reference front() const
PSTech::Utils::PstVector< Target >::value_type
Target value_type
Definition PstVector.h:32
PSTech::Utils::PstVector::begin
const_iterator begin() const
PSTech::Utils::PstVector< Target >::const_iterator
const Target * const_iterator
Definition PstVector.h:39
PSTech::Utils::PstVector< Target >::m_size
size_type m_size
Definition PstVector.h:211
PSTech::Utils::PstVector< Target >::iterator
Target * iterator
Definition PstVector.h:38
PSTech::Utils::PstVector< Target >::resize
void resize(size_type size, const_reference data)
PSTech::Utils::PstVector::cbegin
const_iterator cbegin() const
PSTech::Utils::PstVector::swap
void swap(PstVector &vector) noexcept
PSTech::Utils::PstVector< Target >::size_type
size_t size_type
Definition PstVector.h:33
PSTech::Utils::PstVector::reserve
void reserve(size_type size)
PSTech::Utils::PstVector< Target >::const_pointer
const Target * const_pointer
Definition PstVector.h:35
PSTech::Utils::PstVector::PstVector
PstVector(const PstVector &vector)
PSTech::Utils::PstVector::PstVector
PstVector(size_type size, const_reference data)
PSTech::Utils::PstVector::~PstVector
~PstVector()
PSTech::Utils::PstVector< Target >::size
size_type size() const
PSTech::Utils::PstVector::back
const_reference back() const
PSTech::Utils::PstVector::empty
bool empty() const
PSTech::Utils::PstVector< Target >::pointer
Target * pointer
Definition PstVector.h:34
PSTech::Utils::PstVector::front
reference front()
PSTech::Utils::PstVector::check_bounds
void check_bounds(size_type index) const
PSTech::Utils::PstVector::operator=
PstVector & operator=(PstVector &&vector) noexcept
PSTech::Utils::PstVector::operator=
PstVector & operator=(const PstVector &vector)
PSTech::Utils::PstVector::at
const_reference at(size_type index) const
PSTech::Utils::PstVector::cend
const_iterator cend() const
PSTech::Utils::PstVector< Target >::reference
Target & reference
Definition PstVector.h:36
PSTech::Utils::PstVector< Target >::m_array
pointer m_array
Definition PstVector.h:213
PSTech::Utils::PstVector::PstVector
PstVector()
PSTech::Utils::PstVector::resize_internal
void resize_internal(size_type size, const_pointer data)
PSTech::Utils::PstVector::at
reference at(size_type index)
PSTech::Utils::PstVector::clear
void clear()
PSTech::Utils::PstVector::end
iterator end()
PSTech::Utils::PstVector::end
const_iterator end() const
PSTech::Utils::PstVector::capacity
size_type capacity() const
PSTech::Utils::PstVector::begin
iterator begin()
PSTech::Utils::PstVector< Target >::m_allocated
size_type m_allocated
Definition PstVector.h:212
PSTech::Utils::PstVector::PstVector
PstVector(size_type size)
PSTech::Utils::PstVector< Target >::m_allocator
Allocator m_allocator
Definition PstVector.h:214
PSTech::Utils::PstVector::back
reference back()
PSTech::Utils::PstVector< Target >::const_reference
const Target & const_reference
Definition PstVector.h:37
PSTech::Utils::PstVector::PstVector
PstVector(PstVector &&vector) noexcept
PSTech::Utils
Definition PstArray.h:14
PSTech
Definition ExportedTypeConversions.h:9