Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
TVector.h
Go to the documentation of this file.
1#pragma once
2#include <iterator>
3#include <ostream>
4#include <vector>
5
6namespace sf
7{
8
9template<typename T>
11
18template<typename T>
19class TVector : public std::vector<T>
20{
21 public:
25 typedef std::vector<T> base_type;
29 typedef typename base_type::size_type size_type;
33 typedef typename base_type::value_type value_type;
42
46 static const size_t npos = static_cast<size_type>(-1);
47
51 TVector() = default;
52
56 TVector(const TVector& v);
57
61 TVector(TVector&&) noexcept = default;
62
66 TVector& operator=(const TVector& v) noexcept;
67
71 TVector& operator=(TVector&& v) noexcept;
72
76 template<typename InputIterator>
77 TVector(InputIterator first, InputIterator last);
78
83 TVector(std::initializer_list<value_type> list);
84
88 explicit TVector(const base_type& sv);
89
94 explicit TVector(size_type sz);
95
100 size_type add(const T& t);
101
107
112 TVector& append(const T& t);
113
119
124 TVector& prepend(const T& t);
125
131
137
144 bool addAt(const T& t, size_type index);
145
152 bool addAt(T&& t, size_type index);
153
160 bool detach(const T& t);
161
167 bool detachAt(size_type index);
168
173 [[nodiscard]] bool isEmpty() const;
174
178 void flush();
179
185 void flush(size_type stop, size_type start = 0);
186
191 size_type find(const T&) const;
192
197 [[nodiscard]] size_type count() const;
198
203 T& first();
204
209 const T& first() const noexcept;
210
215 T& last();
216
221 const T& last() const noexcept;
222
226 bool startsWith(T t) const;
227
231 bool endsWith(T t) const;
232
239
245 const T& get(size_type i) const;
246
252
258
266 T& operator[](size_type i);
267
275 const T& operator[](size_type i) const;
276
283 std::ostream& write(std::ostream& os, bool inc_hex) const;
284};
285
286}// namespace sf
287
288// Include all inlined functions and template implementations.
289#include <misc/gen/TVector.hpp>
Definition TVector.h:10
Counted vector having additional methods and operators for ease of usage. This template class extends...
Definition TVector.h:20
base_type::size_type size_type
Size type of this template.
Definition TVector.h:29
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:25
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:33
const iter_type const_iter_type
Iteration const type of the template.
Definition TVector.h:41
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:46
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:37
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