5#ifndef BITCOIN_PREVECTOR_H
6#define BITCOIN_PREVECTOR_H
36template <
unsigned int N,
typename T,
typename Size =
uint32_t,
82 return (&(*
a) - &(*
b));
173 return (&(*
a) - &(*
b));
246 static_assert(
alignof(
char *) %
alignof(
size_type) == 0 &&
247 sizeof(
char *) %
alignof(
size_type) == 0,
248 "size_type cannot have more restrictive alignment "
249 "requirement than pointer");
250 static_assert(
alignof(
char *) %
alignof(T) == 0,
251 "value_type T cannot have more restrictive alignment "
252 "requirement than pointer");
258 return reinterpret_cast<const T *
>(
_union.
direct) + pos;
316 template <
typename InputIterator>
318 while (first != last) {
319 new (
static_cast<void *
>(
dst)) T(*first);
335 template <
typename InputIterator>
356 template <
typename InputIterator>
374 if (&other ==
this) {
452 new (
static_cast<void *
>(ptr)) T(value);
468 template <
typename InputIterator>
479 fill(ptr, first, last);
508 char *
endp = (
char *)&(*
end());
509 if (!std::is_trivially_destructible<T>::value) {
518 memmove(&(*first), &(*last),
endp - ((
char *)(&(*last))));
544 std::swap(
_union, other._union);
545 std::swap(
_size, other._size);
549 if (!std::is_trivially_destructible<T>::value) {
566 if ((*
b1) != (*
b2)) {
576 return !(*
this == other);
bool operator==(const_iterator x) const
const_iterator & operator++()
const_iterator & operator+=(size_type n)
bool operator<(const_iterator x) const
const_iterator & operator-=(size_type n)
std::random_access_iterator_tag iterator_category
const_iterator operator--(int)
bool operator<=(const_iterator x) const
const_iterator operator++(int)
const_iterator(const T *ptr_)
const T * operator->() const
difference_type friend operator-(const_iterator a, const_iterator b)
bool operator!=(const_iterator x) const
const_iterator operator+(size_type n)
bool operator>=(const_iterator x) const
const_iterator & operator--()
const T & operator*() const
const_iterator operator-(size_type n)
const T & operator[](size_type pos) const
bool operator>(const_iterator x) const
const_iterator(iterator x)
const_reverse_iterator(const T *ptr_)
const_reverse_iterator & operator--()
const_reverse_iterator operator--(int)
const_reverse_iterator operator++(int)
std::bidirectional_iterator_tag iterator_category
const_reverse_iterator(reverse_iterator x)
const T * operator->() const
bool operator!=(const_reverse_iterator x) const
const_reverse_iterator & operator++()
const T & operator*() const
bool operator==(const_reverse_iterator x) const
bool operator<(iterator x) const
bool operator==(iterator x) const
difference_type friend operator-(iterator a, iterator b)
bool operator!=(iterator x) const
iterator operator-(size_type n)
bool operator<=(iterator x) const
bool operator>=(iterator x) const
T & operator[](size_type pos)
iterator & operator+=(size_type n)
iterator & operator-=(size_type n)
bool operator>(iterator x) const
const T & operator[](size_type pos) const
std::random_access_iterator_tag iterator_category
iterator operator+(size_type n)
std::bidirectional_iterator_tag iterator_category
reverse_iterator operator++(int)
reverse_iterator & operator--()
const T & operator*() const
bool operator!=(reverse_iterator x) const
reverse_iterator(T *ptr_)
const T * operator->() const
bool operator==(reverse_iterator x) const
reverse_iterator operator--(int)
reverse_iterator & operator++()
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without h...
prevector(prevector< N, T, Size, Diff > &&other)
void change_capacity(size_type new_capacity)
void fill(T *dst, ptrdiff_t count, const T &value=T{})
iterator erase(iterator first, iterator last)
prevector(InputIterator first, InputIterator last)
void swap(prevector< N, T, Size, Diff > &other) noexcept
const value_type & const_reference
prevector & operator=(prevector< N, T, Size, Diff > &&other)
void emplace_back(Args &&...args)
bool operator==(const prevector< N, T, Size, Diff > &other) const
iterator erase(iterator pos)
prevector(size_type n, const T &val)
void fill(T *dst, InputIterator first, InputIterator last)
const T * indirect_ptr(difference_type pos) const
T * direct_ptr(difference_type pos)
const_iterator end() const
direct_or_indirect _union
void assign(InputIterator first, InputIterator last)
void insert(iterator pos, InputIterator first, InputIterator last)
const T * item_ptr(difference_type pos) const
bool operator<(const prevector< N, T, Size, Diff > &other) const
const value_type * data() const
bool operator!=(const prevector< N, T, Size, Diff > &other) const
void reserve(size_type new_capacity)
prevector(const prevector< N, T, Size, Diff > &other)
const T & operator[](size_type pos) const
const T * direct_ptr(difference_type pos) const
void resize_uninitialized(size_type new_size)
const_reverse_iterator rbegin() const
T * item_ptr(difference_type pos)
T * indirect_ptr(difference_type pos)
prevector & operator=(const prevector< N, T, Size, Diff > &other)
void resize(size_type new_size)
size_t allocated_memory() const
iterator insert(iterator pos, const T &value)
reverse_iterator rbegin()
const_reverse_iterator rend() const
const value_type * const_pointer
void assign(size_type n, const T &val)
void insert(iterator pos, size_type count, const T &value)
void push_back(const T &value)
const_iterator begin() const
T & operator[](size_type pos)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
struct prevector::direct_or_indirect::@2 indirect_contents
char direct[sizeof(T) *N]