15template <
unsigned int N,
typename T>
31 const pretype& const_pre_vector = pre_vector;
32 assert(real_vector.size() == pre_vector.size());
33 assert(real_vector.empty() == pre_vector.empty());
34 for (Size
s = 0;
s < real_vector.size();
s++) {
35 assert(real_vector[
s] == pre_vector[
s]);
36 assert(&(pre_vector[
s]) == &(pre_vector.begin()[
s]));
37 assert(&(pre_vector[
s]) == &*(pre_vector.begin() +
s));
38 assert(&(pre_vector[
s]) == &*((pre_vector.end() +
s) - real_vector.size()));
41 assert(pretype(real_vector.begin(), real_vector.end()) == pre_vector);
42 assert(pretype(pre_vector.begin(), pre_vector.end()) == pre_vector);
44 for (
const T& v : pre_vector) {
45 assert(v == real_vector[pos]);
48 for (
const T& v : pre_vector | std::views::reverse) {
50 assert(v == real_vector[pos]);
52 for (
const T& v : const_pre_vector) {
53 assert(v == real_vector[pos]);
56 for (
const T& v : const_pre_vector | std::views::reverse) {
58 assert(v == real_vector[pos]);
64 assert(ss1.size() == ss2.size());
65 for (Size
s = 0;
s < ss1.size();
s++) {
72 real_vector.resize(
s);
73 assert(real_vector.size() ==
s);
80 real_vector.reserve(
s);
81 assert(real_vector.capacity() >=
s);
82 pre_vector.reserve(
s);
83 assert(pre_vector.capacity() >=
s);
86 void insert(Size position,
const T& value)
88 real_vector.insert(real_vector.begin() + position, value);
89 pre_vector.insert(pre_vector.begin() + position, value);
94 real_vector.insert(real_vector.begin() + position,
count, value);
95 pre_vector.insert(pre_vector.begin() + position,
count, value);
101 real_vector.insert(real_vector.begin() + position, first, last);
102 pre_vector.insert(pre_vector.begin() + position, first, last);
105 void erase(Size position)
107 real_vector.erase(real_vector.begin() + position);
108 pre_vector.erase(pre_vector.begin() + position);
111 void erase(Size first, Size last)
113 real_vector.erase(real_vector.begin() + first, real_vector.begin() + last);
114 pre_vector.erase(pre_vector.begin() + first, pre_vector.begin() + last);
117 void update(Size pos,
const T& value)
119 real_vector[pos] = value;
120 pre_vector[pos] = value;
125 real_vector.push_back(value);
126 pre_vector.push_back(value);
131 real_vector.pop_back();
132 pre_vector.pop_back();
141 void assign(Size n,
const T& value)
143 real_vector.assign(n, value);
144 pre_vector.assign(n, value);
149 return real_vector.size();
154 return pre_vector.capacity();
159 pre_vector.shrink_to_fit();
164 real_vector.swap(real_vector_alt);
165 pre_vector.swap(pre_vector_alt);
170 real_vector = std::move(real_vector_alt);
171 real_vector_alt.clear();
172 pre_vector = std::move(pre_vector_alt);
173 pre_vector_alt.clear();
178 real_vector = real_vector_alt;
179 pre_vector = pre_vector_alt;
185 size_t s = real_vector.size() / 2;
186 if (real_vector.capacity() <
s + r) {
187 real_vector.reserve(
s + r);
189 real_vector.resize(
s);
190 pre_vector.resize_uninitialized(
s);
192 real_vector.push_back(v);
194 auto p = pre_vector.size();
195 pre_vector.resize_uninitialized(p + r);
208 prevector_tester<8, int> test;
216 test.insert(position, value);
225 test.insert(position,
count, value);
230 test.erase(beg, beg + del);
239 for (
int k = 0;
k < num; ++
k) {
247 std::vector<int>
values(num);
251 test.resize_uninitialized(
values);
258 test.shrink_to_fit();
266 test.assign(n, value);
280 test.update(pos, value);
Double ended buffer combining vector and stream-like interfaces.
T ConsumeIntegralInRange(T min, T max)
void erase(Size position)
void update(Size pos, const T &value)
prevector< N, T > pretype
std::vector< T > realtype
void assign(Size n, const T &value)
void insert_range(Size position, I first, I last)
void resize_uninitialized(realtype values)
void push_back(const T &value)
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without h...
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
void insert(Tdst &dst, const Tsrc &src)
Simplification of std insertion.
static const int64_t values[]
A selection of numbers that do not trigger int64_t overflow when added/subtracted.