Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
TVector.h
Go to the documentation of this file.
1#pragma once
2#include <ostream>
3#include <vector>
4
5namespace sf
6{
7
8template<typename T>
10
17template<typename T>
18class TVector : public std::vector<T>
19{
20 public:
24 typedef std::vector<T> base_type;
28 typedef typename base_type::size_type size_type;
32 typedef typename base_type::value_type value_type;
41
45 static const size_t npos = static_cast<size_type>(-1);
46
50 TVector() = default;
51
55 TVector(const TVector& v);
56
60 TVector(TVector&&) noexcept = default;
61
65 TVector& operator=(const TVector& v) noexcept;
66
70 TVector& operator=(TVector&& v) noexcept;
71
75 template<typename InputIterator>
76 TVector(InputIterator first, InputIterator last);
77
82 TVector(std::initializer_list<value_type> list);
83
87 explicit TVector(const base_type& sv);
88
93 explicit TVector(size_type sz);
94
99 size_type add(const T& t);
100
106
111 TVector& append(const T& t);
112
118
123 TVector& prepend(const T& t);
124
130
136
143 bool addAt(const T& t, size_type index);
144
151 bool addAt(T&& t, size_type index);
152
159 bool detach(const T& t);
160
166 bool detachAt(size_type index);
167
172 [[nodiscard]] bool isEmpty() const;
173
177 void flush();
178
184 void flush(size_type stop, size_type start = 0);
185
190 size_type find(const T&) const;
191
196 [[nodiscard]] size_type count() const;
197
202 T& first();
203
208 const T& first() const noexcept;
209
214 T& last();
215
220 const T& last() const noexcept;
221
225 bool startsWith(T t) const;
226
230 bool endsWith(T t) const;
231
238
244 const T& get(size_type i) const;
245
251
257
264 T& operator[](size_type i);
265
273 const T& operator[](size_type i) const;
274
281 std::ostream& write(std::ostream& os, bool inc_hex) const;
282};
283
284}// namespace sf
285
286// Include all inlined functions and template implementations.
287#include <misc/gen/TVector.hpp>
Definition TVector.h:9
Counted vector having additional methods and operators for ease of usage. This template class extends...
Definition TVector.h:19
base_type::size_type size_type
Size type of this template.
Definition TVector.h:28
base_type getBase()
Returns the base type to access it methods explicitly.
T & first()
Gets the first element of the vector.
TVector(TVector &&) noexcept=default
Move constructor.
std::vector< T > base_type
Base type of this template .
Definition TVector.h:24
bool detachAt(size_type index)
Removes specific item from the list by index.
T & get(size_type i)
Gets entry from index position.
bool endsWith(T t) const
Checks if the last element is of the passed value.
base_type::value_type value_type
Value type contained by this vector template.
Definition TVector.h:32
const iter_type const_iter_type
Iteration const type of the template.
Definition TVector.h:40
bool isEmpty() const
Returns true when empty false otherwise.
bool addAt(const T &t, size_type index)
Adds an item at index position.
static const size_t npos
Value returned by various member functions when they fail.
Definition TVector.h:45
TVector(const TVector &v)
Copy constructor.
std::ostream & write(std::ostream &os, bool inc_hex) const
TVector()=default
Default constructor.
void flush()
Removes all entries from the vector.
TVector & prepend(const T &t)
Prepends an entry to the vectors items at the beginning of the vector.
size_type count() const
Returns the amount of entries in the vector.
bool startsWith(T t) const
Checks if the first element is of the passed value.
size_type add(const T &t)
Adds item at the end of the vector.
bool detach(const T &t)
Removes specific item from the list by instance. Uses the compare operator from type T to find it.
TIterator< value_type > iter_type
Iteration type of the template.
Definition TVector.h:36
size_type find(const T &) const
Finds an entry by instance in the vector.
T & last()
Gets the last element of the vector.
TVector & append(const T &t)
Appends an entry to the vectors items at the end of the vector.
Definition Application.h:10