PST SDK  5.2.0.0-0eac0f6
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>
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();
55 
61  size_type size() const;
62 
68  size_type capacity() const;
69 
71  bool empty() const;
72 
79  void reserve(size_type size);
80 
86  void resize(size_type size);
87 
93  void resize(size_type size, const_reference data);
94 
99  void clear();
100 
105  void assign(size_type count, const_reference data);
106 
111  void push_back(const_reference data);
112 
117  void push_back(T&& data);
118 
122  void pop_back();
123 
129  const_reference at(size_type index) const;
130 
136  reference at(size_type index);
137 
139  const_reference front() const;
140 
142  reference front();
143 
145  const_reference back() const;
146 
148  reference back();
149 
151  const_iterator cbegin() const;
152 
154  const_iterator begin() const;
155 
157  iterator begin();
158 
160  const_iterator cend() const;
161 
163  const_iterator end() const;
164 
166  iterator end();
167 
169  const_reference operator [] (size_type index) const;
170 
172  reference operator [] (size_type index);
173 
174  private:
176  class Allocator
177  {
178  public:
180  typename PstVector<T>::pointer allocate(typename PstVector<T>::size_type num);
181 
183  void construct(typename PstVector<T>::pointer p);
184 
186  template<class... A>
187  void construct(typename PstVector<T>::pointer p, A&... arg);
188 
190  void construct(typename PstVector<T>::pointer p, T&& data);
191 
192  /* Destroy elements of initialized storage p */
193  void destroy(typename PstVector<T>::pointer p);
194 
195  /* Deallocate storage p of deleted elements */
196  void deallocate(typename PstVector<T>::pointer p);
197  };
198 
202  Allocator m_allocator;
203 
204  void resize_internal(size_type size, const_pointer data);
205 
206  void check_bounds(size_type index) const;
207  };
208 }
209 }
PSTech::Utils::PstVector::Allocator
Definition: PstVector.h:176
PSTech::Utils::PstVector
Basic vector class, cloning std::vector<T>.
Definition: PstVector.h:29
PSTech::Utils::PstVector::pointer
T * pointer
Definition: PstVector.h:34
PSTech::Utils::PstVector::const_pointer
const typedef T * const_pointer
Definition: PstVector.h:35
PSTech::Utils::PstVector::value_type
T value_type
Definition: PstVector.h:32
PSTech::Utils::PstVector::reference
T & reference
Definition: PstVector.h:36
PstBase.h
PST_EXPORT
#define PST_EXPORT
Definition: PstBase.h:12
PSTech::Utils::PstVector::iterator
T * iterator
Definition: PstVector.h:38
PSTech::Utils::PstVector::const_iterator
const typedef T * const_iterator
Definition: PstVector.h:39
PSTech::Utils::PstVector::m_size
size_type m_size
Definition: PstVector.h:199
PSTech::Utils::PstVector::m_array
pointer m_array
Definition: PstVector.h:201
PSTech::Utils::PstVector::size_type
size_t size_type
Definition: PstVector.h:33
PSTech::Utils::PstVector::const_reference
const typedef T & const_reference
Definition: PstVector.h:37
PSTech::Utils::PstVector::m_allocated
size_type m_allocated
Definition: PstVector.h:200
PSTech::Utils::PstVector::m_allocator
Allocator m_allocator
Definition: PstVector.h:202
PSTech
Definition: PstArray.h:10