/root/bitcoin/src/prevector.h
Line | Count | Source |
1 | | // Copyright (c) 2015-present The Bitcoin Core developers |
2 | | // Distributed under the MIT software license, see the accompanying |
3 | | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
4 | | |
5 | | #ifndef BITCOIN_PREVECTOR_H |
6 | | #define BITCOIN_PREVECTOR_H |
7 | | |
8 | | #include <algorithm> |
9 | | #include <cassert> |
10 | | #include <cstddef> |
11 | | #include <cstdint> |
12 | | #include <cstdlib> |
13 | | #include <cstring> |
14 | | #include <iterator> |
15 | | #include <type_traits> |
16 | | #include <utility> |
17 | | |
18 | | /** Implements a drop-in replacement for std::vector<T> which stores up to N |
19 | | * elements directly (without heap allocation). The types Size and Diff are |
20 | | * used to store element counts, and can be any unsigned + signed type. |
21 | | * |
22 | | * Storage layout is either: |
23 | | * - Direct allocation: |
24 | | * - Size _size: the number of used elements (between 0 and N) |
25 | | * - T direct[N]: an array of N elements of type T |
26 | | * (only the first _size are initialized). |
27 | | * - Indirect allocation: |
28 | | * - Size _size: the number of used elements plus N + 1 |
29 | | * - Size capacity: the number of allocated elements |
30 | | * - T* indirect: a pointer to an array of capacity elements of type T |
31 | | * (only the first _size are initialized). |
32 | | * |
33 | | * The data type T must be movable by memmove/realloc(). Once we switch to C++, |
34 | | * move constructors can be used instead. |
35 | | */ |
36 | | template<unsigned int N, typename T, typename Size = uint32_t, typename Diff = int32_t> |
37 | | class prevector { |
38 | | static_assert(std::is_trivially_copyable_v<T>); |
39 | | |
40 | | public: |
41 | | static constexpr unsigned int STATIC_SIZE{N}; |
42 | | |
43 | | typedef Size size_type; |
44 | | typedef Diff difference_type; |
45 | | typedef T value_type; |
46 | | typedef value_type& reference; |
47 | | typedef const value_type& const_reference; |
48 | | typedef value_type* pointer; |
49 | | typedef const value_type* const_pointer; |
50 | | |
51 | | class iterator { |
52 | | T* ptr{}; |
53 | | public: |
54 | | typedef Diff difference_type; |
55 | | typedef T* pointer; |
56 | | typedef T& reference; |
57 | | using element_type = T; |
58 | | using iterator_category = std::contiguous_iterator_tag; |
59 | | iterator() = default; |
60 | 1.55G | iterator(T* ptr_) : ptr(ptr_) {}prevector<16u, unsigned char, unsigned int, int>::iterator::iterator(unsigned char*) Line | Count | Source | 60 | 824M | iterator(T* ptr_) : ptr(ptr_) {} |
prevector<36u, unsigned char, unsigned int, int>::iterator::iterator(unsigned char*) Line | Count | Source | 60 | 732M | iterator(T* ptr_) : ptr(ptr_) {} |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::iterator::iterator(int*) Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::iterator::iterator(unsigned char*) prevector<35u, unsigned char, unsigned int, int>::iterator::iterator(unsigned char*) Line | Count | Source | 60 | 3.64k | iterator(T* ptr_) : ptr(ptr_) {} |
|
61 | 2.29G | T& operator*() const { return *ptr; }prevector<36u, unsigned char, unsigned int, int>::iterator::operator*() const Line | Count | Source | 61 | 650M | T& operator*() const { return *ptr; } |
prevector<16u, unsigned char, unsigned int, int>::iterator::operator*() const Line | Count | Source | 61 | 1.64G | T& operator*() const { return *ptr; } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::iterator::operator*() const Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::iterator::operator*() const prevector<35u, unsigned char, unsigned int, int>::iterator::operator*() const Line | Count | Source | 61 | 3.64k | T& operator*() const { return *ptr; } |
|
62 | 0 | T* operator->() const { return ptr; }Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::iterator::operator->() const Unexecuted instantiation: prevector<36u, unsigned char, unsigned int, int>::iterator::operator->() const Unexecuted instantiation: prevector<16u, unsigned char, unsigned int, int>::iterator::operator->() const Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::iterator::operator->() const |
63 | | T& operator[](size_type pos) const { return ptr[pos]; } |
64 | 136M | iterator& operator++() { ptr++; return *this; } |
65 | | iterator& operator--() { ptr--; return *this; } |
66 | | iterator operator++(int) { iterator copy(*this); ++(*this); return copy; } |
67 | | iterator operator--(int) { iterator copy(*this); --(*this); return copy; } |
68 | 509M | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); }operator-(prevector<36u, unsigned char, unsigned int, int>::iterator, prevector<36u, unsigned char, unsigned int, int>::iterator) Line | Count | Source | 68 | 234M | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } |
operator-(prevector<16u, unsigned char, unsigned int, int>::iterator, prevector<16u, unsigned char, unsigned int, int>::iterator) Line | Count | Source | 68 | 274M | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } |
Unexecuted instantiation: operator-(prevector<8u, int, unsigned int, int>::iterator, prevector<8u, int, unsigned int, int>::iterator) Unexecuted instantiation: operator-(prevector<33u, unsigned char, unsigned int, int>::iterator, prevector<33u, unsigned char, unsigned int, int>::iterator) operator-(prevector<35u, unsigned char, unsigned int, int>::iterator, prevector<35u, unsigned char, unsigned int, int>::iterator) Line | Count | Source | 68 | 1.82k | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } |
|
69 | 0 | iterator operator+(size_type n) const { return iterator(ptr + n); }Unexecuted instantiation: prevector<36u, unsigned char, unsigned int, int>::iterator::operator+(unsigned int) const Unexecuted instantiation: prevector<8u, int, unsigned int, int>::iterator::operator+(unsigned int) const Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::iterator::operator+(unsigned int) const |
70 | | iterator friend operator+(size_type n, iterator x) { return x + n; } |
71 | | iterator& operator+=(size_type n) { ptr += n; return *this; } |
72 | 0 | iterator operator-(size_type n) const { return iterator(ptr - n); } |
73 | | iterator& operator-=(size_type n) { ptr -= n; return *this; } |
74 | 195M | bool operator==(iterator x) const { return ptr == x.ptr; } |
75 | 0 | auto operator<=>(iterator x) const { return ptr <=> x.ptr; }Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::iterator::operator<=>(prevector<33u, unsigned char, unsigned int, int>::iterator) const Unexecuted instantiation: prevector<36u, unsigned char, unsigned int, int>::iterator::operator<=>(prevector<36u, unsigned char, unsigned int, int>::iterator) const Unexecuted instantiation: prevector<16u, unsigned char, unsigned int, int>::iterator::operator<=>(prevector<16u, unsigned char, unsigned int, int>::iterator) const Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::iterator::operator<=>(prevector<35u, unsigned char, unsigned int, int>::iterator) const |
76 | | }; |
77 | | |
78 | | class const_iterator { |
79 | | const T* ptr{}; |
80 | | public: |
81 | | typedef Diff difference_type; |
82 | | typedef const T* pointer; |
83 | | typedef const T& reference; |
84 | | using element_type = const T; |
85 | | using iterator_category = std::contiguous_iterator_tag; |
86 | | const_iterator() = default; |
87 | 7.15G | const_iterator(const T* ptr_) : ptr(ptr_) {}prevector<16u, unsigned char, unsigned int, int>::const_iterator::const_iterator(unsigned char const*) Line | Count | Source | 87 | 1.79G | const_iterator(const T* ptr_) : ptr(ptr_) {} |
prevector<36u, unsigned char, unsigned int, int>::const_iterator::const_iterator(unsigned char const*) Line | Count | Source | 87 | 5.36G | const_iterator(const T* ptr_) : ptr(ptr_) {} |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::const_iterator::const_iterator(int const*) |
88 | 0 | const_iterator(iterator x) : ptr(&(*x)) {} |
89 | 38.1G | const T& operator*() const { return *ptr; }prevector<36u, unsigned char, unsigned int, int>::const_iterator::operator*() const Line | Count | Source | 89 | 31.2G | const T& operator*() const { return *ptr; } |
prevector<16u, unsigned char, unsigned int, int>::const_iterator::operator*() const Line | Count | Source | 89 | 6.86G | const T& operator*() const { return *ptr; } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::const_iterator::operator*() const |
90 | 0 | const T* operator->() const { return ptr; }Unexecuted instantiation: prevector<36u, unsigned char, unsigned int, int>::const_iterator::operator->() const Unexecuted instantiation: prevector<16u, unsigned char, unsigned int, int>::const_iterator::operator->() const |
91 | 0 | const T& operator[](size_type pos) const { return ptr[pos]; }Unexecuted instantiation: prevector<8u, int, unsigned int, int>::const_iterator::operator[](unsigned int) const Unexecuted instantiation: prevector<36u, unsigned char, unsigned int, int>::const_iterator::operator[](unsigned int) const |
92 | 31.0G | const_iterator& operator++() { ptr++; return *this; }prevector<36u, unsigned char, unsigned int, int>::const_iterator::operator++() Line | Count | Source | 92 | 25.6G | const_iterator& operator++() { ptr++; return *this; } |
prevector<16u, unsigned char, unsigned int, int>::const_iterator::operator++() Line | Count | Source | 92 | 5.35G | const_iterator& operator++() { ptr++; return *this; } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::const_iterator::operator++() |
93 | 0 | const_iterator& operator--() { ptr--; return *this; }Unexecuted instantiation: prevector<8u, int, unsigned int, int>::const_iterator::operator--() Unexecuted instantiation: prevector<36u, unsigned char, unsigned int, int>::const_iterator::operator--() |
94 | 914M | const_iterator operator++(int) { const_iterator copy(*this); ++(*this); return copy; } |
95 | | const_iterator operator--(int) { const_iterator copy(*this); --(*this); return copy; } |
96 | 2.98G | difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); }operator-(prevector<36u, unsigned char, unsigned int, int>::const_iterator, prevector<36u, unsigned char, unsigned int, int>::const_iterator) Line | Count | Source | 96 | 2.70G | difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); } |
operator-(prevector<16u, unsigned char, unsigned int, int>::const_iterator, prevector<16u, unsigned char, unsigned int, int>::const_iterator) Line | Count | Source | 96 | 274M | difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); } |
Unexecuted instantiation: operator-(prevector<8u, int, unsigned int, int>::const_iterator, prevector<8u, int, unsigned int, int>::const_iterator) |
97 | 31.5M | const_iterator operator+(size_type n) const { return const_iterator(ptr + n); }Unexecuted instantiation: prevector<8u, int, unsigned int, int>::const_iterator::operator+(unsigned int) const prevector<36u, unsigned char, unsigned int, int>::const_iterator::operator+(unsigned int) const Line | Count | Source | 97 | 31.5M | const_iterator operator+(size_type n) const { return const_iterator(ptr + n); } |
|
98 | | const_iterator friend operator+(size_type n, const_iterator x) { return x + n; } |
99 | 747M | const_iterator& operator+=(size_type n) { ptr += n; return *this; } |
100 | 0 | const_iterator operator-(size_type n) const { return const_iterator(ptr - n); }Unexecuted instantiation: prevector<8u, int, unsigned int, int>::const_iterator::operator-(unsigned int) const Unexecuted instantiation: prevector<36u, unsigned char, unsigned int, int>::const_iterator::operator-(unsigned int) const |
101 | | const_iterator& operator-=(size_type n) { ptr -= n; return *this; } |
102 | 31.5G | bool operator==(const_iterator x) const { return ptr == x.ptr; }prevector<36u, unsigned char, unsigned int, int>::const_iterator::operator==(prevector<36u, unsigned char, unsigned int, int>::const_iterator) const Line | Count | Source | 102 | 25.7G | bool operator==(const_iterator x) const { return ptr == x.ptr; } |
prevector<16u, unsigned char, unsigned int, int>::const_iterator::operator==(prevector<16u, unsigned char, unsigned int, int>::const_iterator) const Line | Count | Source | 102 | 5.76G | bool operator==(const_iterator x) const { return ptr == x.ptr; } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::const_iterator::operator==(prevector<8u, int, unsigned int, int>::const_iterator) const |
103 | 2.30G | auto operator<=>(const_iterator x) const { return ptr <=> x.ptr; }prevector<36u, unsigned char, unsigned int, int>::const_iterator::operator<=>(prevector<36u, unsigned char, unsigned int, int>::const_iterator) const Line | Count | Source | 103 | 2.30G | auto operator<=>(const_iterator x) const { return ptr <=> x.ptr; } |
Unexecuted instantiation: prevector<16u, unsigned char, unsigned int, int>::const_iterator::operator<=>(prevector<16u, unsigned char, unsigned int, int>::const_iterator) const Unexecuted instantiation: prevector<8u, int, unsigned int, int>::const_iterator::operator<=>(prevector<8u, int, unsigned int, int>::const_iterator) const |
104 | | }; |
105 | | |
106 | | private: |
107 | | #pragma pack(push, 1) |
108 | | union direct_or_indirect { |
109 | | char direct[sizeof(T) * N]; |
110 | | struct { |
111 | | char* indirect; |
112 | | size_type capacity; |
113 | | } indirect_contents; |
114 | | }; |
115 | | #pragma pack(pop) |
116 | | alignas(char*) direct_or_indirect _union = {}; |
117 | | size_type _size = 0; |
118 | | |
119 | | static_assert(alignof(char*) % alignof(size_type) == 0 && sizeof(char*) % alignof(size_type) == 0, "size_type cannot have more restrictive alignment requirement than pointer"); |
120 | | static_assert(alignof(char*) % alignof(T) == 0, "value_type T cannot have more restrictive alignment requirement than pointer"); |
121 | | |
122 | 3.56G | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; }prevector<36u, unsigned char, unsigned int, int>::direct_ptr(int) Line | Count | Source | 122 | 2.03G | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::direct_ptr(int) prevector<16u, unsigned char, unsigned int, int>::direct_ptr(int) Line | Count | Source | 122 | 1.52G | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::direct_ptr(int) prevector<35u, unsigned char, unsigned int, int>::direct_ptr(int) Line | Count | Source | 122 | 7.29k | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } |
Unexecuted instantiation: prevector<4u, Network, unsigned int, int>::direct_ptr(int) |
123 | 9.04G | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; }prevector<36u, unsigned char, unsigned int, int>::direct_ptr(int) const Line | Count | Source | 123 | 5.56G | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } |
prevector<16u, unsigned char, unsigned int, int>::direct_ptr(int) const Line | Count | Source | 123 | 3.48G | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::direct_ptr(int) const Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::direct_ptr(int) const |
124 | 483M | T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect_contents.indirect) + pos; }prevector<36u, unsigned char, unsigned int, int>::indirect_ptr(int) Line | Count | Source | 124 | 461M | T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect_contents.indirect) + pos; } |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::indirect_ptr(int) prevector<16u, unsigned char, unsigned int, int>::indirect_ptr(int) Line | Count | Source | 124 | 22.4M | T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect_contents.indirect) + pos; } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::indirect_ptr(int) Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::indirect_ptr(int) Unexecuted instantiation: prevector<4u, Network, unsigned int, int>::indirect_ptr(int) |
125 | 2.47G | const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect_contents.indirect) + pos; }prevector<36u, unsigned char, unsigned int, int>::indirect_ptr(int) const Line | Count | Source | 125 | 2.42G | const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect_contents.indirect) + pos; } |
prevector<16u, unsigned char, unsigned int, int>::indirect_ptr(int) const Line | Count | Source | 125 | 44.3M | const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect_contents.indirect) + pos; } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::indirect_ptr(int) const Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::indirect_ptr(int) const |
126 | 37.6G | bool is_direct() const { return _size <= N; }prevector<36u, unsigned char, unsigned int, int>::is_direct() const Line | Count | Source | 126 | 29.0G | bool is_direct() const { return _size <= N; } |
prevector<33u, unsigned char, unsigned int, int>::is_direct() const Line | Count | Source | 126 | 350k | bool is_direct() const { return _size <= N; } |
prevector<16u, unsigned char, unsigned int, int>::is_direct() const Line | Count | Source | 126 | 8.57G | bool is_direct() const { return _size <= N; } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::is_direct() const prevector<35u, unsigned char, unsigned int, int>::is_direct() const Line | Count | Source | 126 | 17.3k | bool is_direct() const { return _size <= N; } |
Unexecuted instantiation: prevector<4u, Network, unsigned int, int>::is_direct() const |
127 | | |
128 | 1.98G | void change_capacity(size_type new_capacity) { |
129 | 1.98G | if (new_capacity <= N) { |
130 | 1.76G | if (!is_direct()) { |
131 | 0 | T* indirect = indirect_ptr(0); |
132 | 0 | T* src = indirect; |
133 | 0 | T* dst = direct_ptr(0); |
134 | 0 | memcpy(dst, src, size() * sizeof(T)); |
135 | 0 | free(indirect); |
136 | 0 | _size -= N + 1; |
137 | 0 | } |
138 | 1.76G | } else { |
139 | 225M | if (!is_direct()) { |
140 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert |
141 | | success. These should instead use an allocator or new/delete so that handlers |
142 | | are called as necessary, but performance would be slightly degraded by doing so. */ |
143 | 0 | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); |
144 | 0 | assert(_union.indirect_contents.indirect); |
145 | 0 | _union.indirect_contents.capacity = new_capacity; |
146 | 225M | } else { |
147 | 225M | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); |
148 | 225M | assert(new_indirect); |
149 | 225M | T* src = direct_ptr(0); |
150 | 225M | T* dst = reinterpret_cast<T*>(new_indirect); |
151 | 225M | memcpy(dst, src, size() * sizeof(T)); |
152 | 225M | _union.indirect_contents.indirect = new_indirect; |
153 | 225M | _union.indirect_contents.capacity = new_capacity; |
154 | 225M | _size += N + 1; |
155 | 225M | } |
156 | 225M | } |
157 | 1.98G | } prevector<36u, unsigned char, unsigned int, int>::change_capacity(unsigned int) Line | Count | Source | 128 | 1.54G | void change_capacity(size_type new_capacity) { | 129 | 1.54G | if (new_capacity <= N) { | 130 | 1.33G | if (!is_direct()) { | 131 | 0 | T* indirect = indirect_ptr(0); | 132 | 0 | T* src = indirect; | 133 | 0 | T* dst = direct_ptr(0); | 134 | 0 | memcpy(dst, src, size() * sizeof(T)); | 135 | 0 | free(indirect); | 136 | 0 | _size -= N + 1; | 137 | 0 | } | 138 | 1.33G | } else { | 139 | 203M | if (!is_direct()) { | 140 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert | 141 | | success. These should instead use an allocator or new/delete so that handlers | 142 | | are called as necessary, but performance would be slightly degraded by doing so. */ | 143 | 0 | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); | 144 | 0 | assert(_union.indirect_contents.indirect); | 145 | 0 | _union.indirect_contents.capacity = new_capacity; | 146 | 203M | } else { | 147 | 203M | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); | 148 | 203M | assert(new_indirect); | 149 | 203M | T* src = direct_ptr(0); | 150 | 203M | T* dst = reinterpret_cast<T*>(new_indirect); | 151 | 203M | memcpy(dst, src, size() * sizeof(T)); | 152 | 203M | _union.indirect_contents.indirect = new_indirect; | 153 | 203M | _union.indirect_contents.capacity = new_capacity; | 154 | 203M | _size += N + 1; | 155 | 203M | } | 156 | 203M | } | 157 | 1.54G | } |
prevector<16u, unsigned char, unsigned int, int>::change_capacity(unsigned int) Line | Count | Source | 128 | 446M | void change_capacity(size_type new_capacity) { | 129 | 446M | if (new_capacity <= N) { | 130 | 423M | if (!is_direct()) { | 131 | 0 | T* indirect = indirect_ptr(0); | 132 | 0 | T* src = indirect; | 133 | 0 | T* dst = direct_ptr(0); | 134 | 0 | memcpy(dst, src, size() * sizeof(T)); | 135 | 0 | free(indirect); | 136 | 0 | _size -= N + 1; | 137 | 0 | } | 138 | 423M | } else { | 139 | 22.3M | if (!is_direct()) { | 140 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert | 141 | | success. These should instead use an allocator or new/delete so that handlers | 142 | | are called as necessary, but performance would be slightly degraded by doing so. */ | 143 | 0 | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); | 144 | 0 | assert(_union.indirect_contents.indirect); | 145 | 0 | _union.indirect_contents.capacity = new_capacity; | 146 | 22.3M | } else { | 147 | 22.3M | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); | 148 | 22.3M | assert(new_indirect); | 149 | 22.3M | T* src = direct_ptr(0); | 150 | 22.3M | T* dst = reinterpret_cast<T*>(new_indirect); | 151 | 22.3M | memcpy(dst, src, size() * sizeof(T)); | 152 | 22.3M | _union.indirect_contents.indirect = new_indirect; | 153 | 22.3M | _union.indirect_contents.capacity = new_capacity; | 154 | 22.3M | _size += N + 1; | 155 | 22.3M | } | 156 | 22.3M | } | 157 | 446M | } |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::change_capacity(unsigned int) Unexecuted instantiation: prevector<8u, int, unsigned int, int>::change_capacity(unsigned int) prevector<35u, unsigned char, unsigned int, int>::change_capacity(unsigned int) Line | Count | Source | 128 | 912 | void change_capacity(size_type new_capacity) { | 129 | 912 | if (new_capacity <= N) { | 130 | 912 | if (!is_direct()) { | 131 | 0 | T* indirect = indirect_ptr(0); | 132 | 0 | T* src = indirect; | 133 | 0 | T* dst = direct_ptr(0); | 134 | 0 | memcpy(dst, src, size() * sizeof(T)); | 135 | 0 | free(indirect); | 136 | 0 | _size -= N + 1; | 137 | 0 | } | 138 | 912 | } else { | 139 | 0 | if (!is_direct()) { | 140 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert | 141 | | success. These should instead use an allocator or new/delete so that handlers | 142 | | are called as necessary, but performance would be slightly degraded by doing so. */ | 143 | 0 | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); | 144 | 0 | assert(_union.indirect_contents.indirect); | 145 | 0 | _union.indirect_contents.capacity = new_capacity; | 146 | 0 | } else { | 147 | 0 | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); | 148 | 0 | assert(new_indirect); | 149 | 0 | T* src = direct_ptr(0); | 150 | 0 | T* dst = reinterpret_cast<T*>(new_indirect); | 151 | 0 | memcpy(dst, src, size() * sizeof(T)); | 152 | 0 | _union.indirect_contents.indirect = new_indirect; | 153 | 0 | _union.indirect_contents.capacity = new_capacity; | 154 | 0 | _size += N + 1; | 155 | 0 | } | 156 | 0 | } | 157 | 912 | } |
Unexecuted instantiation: prevector<4u, Network, unsigned int, int>::change_capacity(unsigned int) |
158 | | |
159 | 3.81G | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos)3.33G : indirect_ptr(pos)483M ; }prevector<36u, unsigned char, unsigned int, int>::item_ptr(int) Line | Count | Source | 159 | 2.29G | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos)1.83G : indirect_ptr(pos)461M ; } |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::item_ptr(int) prevector<16u, unsigned char, unsigned int, int>::item_ptr(int) Line | Count | Source | 159 | 1.52G | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos)1.50G : indirect_ptr(pos)22.4M ; } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::item_ptr(int) prevector<35u, unsigned char, unsigned int, int>::item_ptr(int) Line | Count | Source | 159 | 7.29k | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos)0 ; } |
Unexecuted instantiation: prevector<4u, Network, unsigned int, int>::item_ptr(int) |
160 | 11.5G | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos)9.04G : indirect_ptr(pos)2.47G ; }prevector<36u, unsigned char, unsigned int, int>::item_ptr(int) const Line | Count | Source | 160 | 7.99G | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos)5.56G : indirect_ptr(pos)2.42G ; } |
prevector<16u, unsigned char, unsigned int, int>::item_ptr(int) const Line | Count | Source | 160 | 3.52G | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos)3.48G : indirect_ptr(pos)44.3M ; } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::item_ptr(int) const Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::item_ptr(int) const |
161 | | |
162 | 316M | void fill(T* dst, ptrdiff_t count, const T& value = T{}) { |
163 | 316M | std::fill_n(dst, count, value); |
164 | 316M | } prevector<36u, unsigned char, unsigned int, int>::fill(unsigned char*, long, unsigned char const&) Line | Count | Source | 162 | 36.8M | void fill(T* dst, ptrdiff_t count, const T& value = T{}) { | 163 | 36.8M | std::fill_n(dst, count, value); | 164 | 36.8M | } |
prevector<16u, unsigned char, unsigned int, int>::fill(unsigned char*, long, unsigned char const&) Line | Count | Source | 162 | 279M | void fill(T* dst, ptrdiff_t count, const T& value = T{}) { | 163 | 279M | std::fill_n(dst, count, value); | 164 | 279M | } |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::fill(unsigned char*, long, unsigned char const&) Unexecuted instantiation: prevector<8u, int, unsigned int, int>::fill(int*, long, int const&) |
165 | | |
166 | | template <std::input_iterator InputIterator> |
167 | 1.64G | void fill(T* dst, InputIterator first, InputIterator last) { |
168 | 30.7G | while (first != last) { |
169 | 29.1G | new(static_cast<void*>(dst)) T(*first); |
170 | 29.1G | ++dst; |
171 | 29.1G | ++first; |
172 | 29.1G | } |
173 | 1.64G | } Unexecuted instantiation: void prevector<36u, unsigned char, unsigned int, int>::fill<unsigned char const*>(unsigned char*, unsigned char const*, unsigned char const*) void prevector<36u, unsigned char, unsigned int, int>::fill<__gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>>(unsigned char*, __gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>) Line | Count | Source | 167 | 89.2M | void fill(T* dst, InputIterator first, InputIterator last) { | 168 | 218M | while (first != last) { | 169 | 129M | new(static_cast<void*>(dst)) T(*first); | 170 | 129M | ++dst; | 171 | 129M | ++first; | 172 | 129M | } | 173 | 89.2M | } |
void prevector<36u, unsigned char, unsigned int, int>::fill<prevector<36u, unsigned char, unsigned int, int>::const_iterator>(unsigned char*, prevector<36u, unsigned char, unsigned int, int>::const_iterator, prevector<36u, unsigned char, unsigned int, int>::const_iterator) Line | Count | Source | 167 | 1.13G | void fill(T* dst, InputIterator first, InputIterator last) { | 168 | 24.7G | while (first != last) { | 169 | 23.6G | new(static_cast<void*>(dst)) T(*first); | 170 | 23.6G | ++dst; | 171 | 23.6G | ++first; | 172 | 23.6G | } | 173 | 1.13G | } |
void prevector<16u, unsigned char, unsigned int, int>::fill<prevector<16u, unsigned char, unsigned int, int>::const_iterator>(unsigned char*, prevector<16u, unsigned char, unsigned int, int>::const_iterator, prevector<16u, unsigned char, unsigned int, int>::const_iterator) Line | Count | Source | 167 | 417M | void fill(T* dst, InputIterator first, InputIterator last) { | 168 | 5.76G | while (first != last) { | 169 | 5.34G | new(static_cast<void*>(dst)) T(*first); | 170 | 5.34G | ++dst; | 171 | 5.34G | ++first; | 172 | 5.34G | } | 173 | 417M | } |
void prevector<36u, unsigned char, unsigned int, int>::fill<__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>>(unsigned char*, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>) Line | Count | Source | 167 | 5.40M | void fill(T* dst, InputIterator first, InputIterator last) { | 168 | 10.8M | while (first != last) { | 169 | 5.40M | new(static_cast<void*>(dst)) T(*first); | 170 | 5.40M | ++dst; | 171 | 5.40M | ++first; | 172 | 5.40M | } | 173 | 5.40M | } |
Unexecuted instantiation: void prevector<36u, unsigned char, unsigned int, int>::fill<prevector<36u, unsigned char, unsigned int, int>::iterator>(unsigned char*, prevector<36u, unsigned char, unsigned int, int>::iterator, prevector<36u, unsigned char, unsigned int, int>::iterator) Unexecuted instantiation: void prevector<8u, int, unsigned int, int>::fill<int*>(int*, int*, int*) Unexecuted instantiation: void prevector<8u, int, unsigned int, int>::fill<prevector<8u, int, unsigned int, int>::const_iterator>(int*, prevector<8u, int, unsigned int, int>::const_iterator, prevector<8u, int, unsigned int, int>::const_iterator) Unexecuted instantiation: void prevector<8u, int, unsigned int, int>::fill<__gnu_cxx::__normal_iterator<int const*, std::vector<int, std::allocator<int>>>>(int*, __gnu_cxx::__normal_iterator<int const*, std::vector<int, std::allocator<int>>>, __gnu_cxx::__normal_iterator<int const*, std::vector<int, std::allocator<int>>>) Unexecuted instantiation: void prevector<33u, unsigned char, unsigned int, int>::fill<__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>>(unsigned char*, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>) Unexecuted instantiation: void prevector<36u, unsigned char, unsigned int, int>::fill<__gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>>(unsigned char*, __gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>, __gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>) void prevector<16u, unsigned char, unsigned int, int>::fill<__gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>>(unsigned char*, __gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>) Line | Count | Source | 167 | 753k | void fill(T* dst, InputIterator first, InputIterator last) { | 168 | 12.8M | while (first != last) { | 169 | 12.0M | new(static_cast<void*>(dst)) T(*first); | 170 | 12.0M | ++dst; | 171 | 12.0M | ++first; | 172 | 12.0M | } | 173 | 753k | } |
void prevector<16u, unsigned char, unsigned int, int>::fill<unsigned char*>(unsigned char*, unsigned char*, unsigned char*) Line | Count | Source | 167 | 528k | void fill(T* dst, InputIterator first, InputIterator last) { | 168 | 5.80M | while (first != last) { | 169 | 5.28M | new(static_cast<void*>(dst)) T(*first); | 170 | 5.28M | ++dst; | 171 | 5.28M | ++first; | 172 | 5.28M | } | 173 | 528k | } |
Unexecuted instantiation: void prevector<16u, unsigned char, unsigned int, int>::fill<__gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>>(unsigned char*, __gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>, __gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>) Unexecuted instantiation: void prevector<16u, unsigned char, unsigned int, int>::fill<unsigned char const*>(unsigned char*, unsigned char const*, unsigned char const*) void prevector<35u, unsigned char, unsigned int, int>::fill<__gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>>(unsigned char*, __gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>) Line | Count | Source | 167 | 912 | void fill(T* dst, InputIterator first, InputIterator last) { | 168 | 30.0k | while (first != last) { | 169 | 29.1k | new(static_cast<void*>(dst)) T(*first); | 170 | 29.1k | ++dst; | 171 | 29.1k | ++first; | 172 | 29.1k | } | 173 | 912 | } |
void prevector<35u, unsigned char, unsigned int, int>::fill<unsigned char*>(unsigned char*, unsigned char*, unsigned char*) Line | Count | Source | 167 | 912 | void fill(T* dst, InputIterator first, InputIterator last) { | 168 | 2.73k | while (first != last) { | 169 | 1.82k | new(static_cast<void*>(dst)) T(*first); | 170 | 1.82k | ++dst; | 171 | 1.82k | ++first; | 172 | 1.82k | } | 173 | 912 | } |
void prevector<35u, unsigned char, unsigned int, int>::fill<unsigned char const*>(unsigned char*, unsigned char const*, unsigned char const*) Line | Count | Source | 167 | 912 | void fill(T* dst, InputIterator first, InputIterator last) { | 168 | 1.82k | while (first != last) { | 169 | 912 | new(static_cast<void*>(dst)) T(*first); | 170 | 912 | ++dst; | 171 | 912 | ++first; | 172 | 912 | } | 173 | 912 | } |
|
174 | | |
175 | | public: |
176 | 928 | void assign(size_type n, const T& val) { |
177 | 928 | clear(); |
178 | 928 | if (capacity() < n) { |
179 | 0 | change_capacity(n); |
180 | 0 | } |
181 | 928 | _size += n; |
182 | 928 | fill(item_ptr(0), n, val); |
183 | 928 | } prevector<16u, unsigned char, unsigned int, int>::assign(unsigned int, unsigned char const&) Line | Count | Source | 176 | 928 | void assign(size_type n, const T& val) { | 177 | 928 | clear(); | 178 | 928 | if (capacity() < n) { | 179 | 0 | change_capacity(n); | 180 | 0 | } | 181 | 928 | _size += n; | 182 | 928 | fill(item_ptr(0), n, val); | 183 | 928 | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::assign(unsigned int, int const&) |
184 | | |
185 | | template <std::input_iterator InputIterator> |
186 | 538M | void assign(InputIterator first, InputIterator last) { |
187 | 538M | size_type n = last - first; |
188 | 538M | clear(); |
189 | 538M | if (capacity() < n) { |
190 | 21.7M | change_capacity(n); |
191 | 21.7M | } |
192 | 538M | _size += n; |
193 | 538M | fill(item_ptr(0), first, last); |
194 | 538M | } void prevector<16u, unsigned char, unsigned int, int>::assign<prevector<16u, unsigned char, unsigned int, int>::const_iterator>(prevector<16u, unsigned char, unsigned int, int>::const_iterator, prevector<16u, unsigned char, unsigned int, int>::const_iterator) Line | Count | Source | 186 | 273M | void assign(InputIterator first, InputIterator last) { | 187 | 273M | size_type n = last - first; | 188 | 273M | clear(); | 189 | 273M | if (capacity() < n) { | 190 | 21.7M | change_capacity(n); | 191 | 21.7M | } | 192 | 273M | _size += n; | 193 | 273M | fill(item_ptr(0), first, last); | 194 | 273M | } |
void prevector<36u, unsigned char, unsigned int, int>::assign<prevector<36u, unsigned char, unsigned int, int>::const_iterator>(prevector<36u, unsigned char, unsigned int, int>::const_iterator, prevector<36u, unsigned char, unsigned int, int>::const_iterator) Line | Count | Source | 186 | 263M | void assign(InputIterator first, InputIterator last) { | 187 | 263M | size_type n = last - first; | 188 | 263M | clear(); | 189 | 263M | if (capacity() < n) { | 190 | 0 | change_capacity(n); | 191 | 0 | } | 192 | 263M | _size += n; | 193 | 263M | fill(item_ptr(0), first, last); | 194 | 263M | } |
Unexecuted instantiation: void prevector<8u, int, unsigned int, int>::assign<prevector<8u, int, unsigned int, int>::const_iterator>(prevector<8u, int, unsigned int, int>::const_iterator, prevector<8u, int, unsigned int, int>::const_iterator) Unexecuted instantiation: void prevector<33u, unsigned char, unsigned int, int>::assign<__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>>(__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>) void prevector<16u, unsigned char, unsigned int, int>::assign<__gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>>(__gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>) Line | Count | Source | 186 | 753k | void assign(InputIterator first, InputIterator last) { | 187 | 753k | size_type n = last - first; | 188 | 753k | clear(); | 189 | 753k | if (capacity() < n) { | 190 | 0 | change_capacity(n); | 191 | 0 | } | 192 | 753k | _size += n; | 193 | 753k | fill(item_ptr(0), first, last); | 194 | 753k | } |
void prevector<16u, unsigned char, unsigned int, int>::assign<unsigned char*>(unsigned char*, unsigned char*) Line | Count | Source | 186 | 528k | void assign(InputIterator first, InputIterator last) { | 187 | 528k | size_type n = last - first; | 188 | 528k | clear(); | 189 | 528k | if (capacity() < n) { | 190 | 0 | change_capacity(n); | 191 | 0 | } | 192 | 528k | _size += n; | 193 | 528k | fill(item_ptr(0), first, last); | 194 | 528k | } |
Unexecuted instantiation: void prevector<16u, unsigned char, unsigned int, int>::assign<__gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>>(__gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>, __gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>) Unexecuted instantiation: void prevector<16u, unsigned char, unsigned int, int>::assign<unsigned char const*>(unsigned char const*, unsigned char const*) |
195 | | |
196 | 1.04G | prevector() = default; prevector<36u, unsigned char, unsigned int, int>::prevector() Line | Count | Source | 196 | 1.04G | prevector() = default; |
prevector<33u, unsigned char, unsigned int, int>::prevector() Line | Count | Source | 196 | 350k | prevector() = default; |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::prevector() Unexecuted instantiation: prevector<4u, Network, unsigned int, int>::prevector() |
197 | | |
198 | | explicit prevector(size_type n) { |
199 | | resize(n); |
200 | | } |
201 | | |
202 | 279M | explicit prevector(size_type n, const T& val) { |
203 | 279M | change_capacity(n); |
204 | 279M | _size += n; |
205 | 279M | fill(item_ptr(0), n, val); |
206 | 279M | } Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::prevector(unsigned int, unsigned char const&) prevector<16u, unsigned char, unsigned int, int>::prevector(unsigned int, unsigned char const&) Line | Count | Source | 202 | 279M | explicit prevector(size_type n, const T& val) { | 203 | 279M | change_capacity(n); | 204 | 279M | _size += n; | 205 | 279M | fill(item_ptr(0), n, val); | 206 | 279M | } |
|
207 | | |
208 | | template <std::input_iterator InputIterator> |
209 | 5.40M | prevector(InputIterator first, InputIterator last) { |
210 | 5.40M | size_type n = last - first; |
211 | 5.40M | change_capacity(n); |
212 | 5.40M | _size += n; |
213 | 5.40M | fill(item_ptr(0), first, last); |
214 | 5.40M | } prevector<36u, unsigned char, unsigned int, int>::prevector<__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>>(__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>) Line | Count | Source | 209 | 5.40M | prevector(InputIterator first, InputIterator last) { | 210 | 5.40M | size_type n = last - first; | 211 | 5.40M | change_capacity(n); | 212 | 5.40M | _size += n; | 213 | 5.40M | fill(item_ptr(0), first, last); | 214 | 5.40M | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::prevector<__gnu_cxx::__normal_iterator<int const*, std::vector<int, std::allocator<int>>>>(__gnu_cxx::__normal_iterator<int const*, std::vector<int, std::allocator<int>>>, __gnu_cxx::__normal_iterator<int const*, std::vector<int, std::allocator<int>>>) Unexecuted instantiation: prevector<8u, int, unsigned int, int>::prevector<prevector<8u, int, unsigned int, int>::const_iterator>(prevector<8u, int, unsigned int, int>::const_iterator, prevector<8u, int, unsigned int, int>::const_iterator) Unexecuted instantiation: prevector<36u, unsigned char, unsigned int, int>::prevector<__gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>>(__gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>, __gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>) prevector<35u, unsigned char, unsigned int, int>::prevector<__gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>>(__gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>) Line | Count | Source | 209 | 912 | prevector(InputIterator first, InputIterator last) { | 210 | 912 | size_type n = last - first; | 211 | 912 | change_capacity(n); | 212 | 912 | _size += n; | 213 | 912 | fill(item_ptr(0), first, last); | 214 | 912 | } |
Unexecuted instantiation: prevector<36u, unsigned char, unsigned int, int>::prevector<__gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>>(__gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>) Unexecuted instantiation: prevector<36u, unsigned char, unsigned int, int>::prevector<prevector<36u, unsigned char, unsigned int, int>::const_iterator>(prevector<36u, unsigned char, unsigned int, int>::const_iterator, prevector<36u, unsigned char, unsigned int, int>::const_iterator) |
215 | | |
216 | 1.01G | prevector(const prevector<N, T, Size, Diff>& other) { |
217 | 1.01G | size_type n = other.size(); |
218 | 1.01G | change_capacity(n); |
219 | 1.01G | _size += n; |
220 | 1.01G | fill(item_ptr(0), other.begin(), other.end()); |
221 | 1.01G | } prevector<16u, unsigned char, unsigned int, int>::prevector(prevector<16u, unsigned char, unsigned int, int> const&) Line | Count | Source | 216 | 144M | prevector(const prevector<N, T, Size, Diff>& other) { | 217 | 144M | size_type n = other.size(); | 218 | 144M | change_capacity(n); | 219 | 144M | _size += n; | 220 | 144M | fill(item_ptr(0), other.begin(), other.end()); | 221 | 144M | } |
prevector<36u, unsigned char, unsigned int, int>::prevector(prevector<36u, unsigned char, unsigned int, int> const&) Line | Count | Source | 216 | 870M | prevector(const prevector<N, T, Size, Diff>& other) { | 217 | 870M | size_type n = other.size(); | 218 | 870M | change_capacity(n); | 219 | 870M | _size += n; | 220 | 870M | fill(item_ptr(0), other.begin(), other.end()); | 221 | 870M | } |
|
222 | | |
223 | | prevector(prevector<N, T, Size, Diff>&& other) noexcept |
224 | 70.3M | : _union(std::move(other._union)), _size(other._size) |
225 | 70.3M | { |
226 | 70.3M | other._size = 0; |
227 | 70.3M | } prevector<16u, unsigned char, unsigned int, int>::prevector(prevector<16u, unsigned char, unsigned int, int>&&) Line | Count | Source | 224 | 441k | : _union(std::move(other._union)), _size(other._size) | 225 | 441k | { | 226 | 441k | other._size = 0; | 227 | 441k | } |
prevector<36u, unsigned char, unsigned int, int>::prevector(prevector<36u, unsigned char, unsigned int, int>&&) Line | Count | Source | 224 | 69.9M | : _union(std::move(other._union)), _size(other._size) | 225 | 69.9M | { | 226 | 69.9M | other._size = 0; | 227 | 69.9M | } |
|
228 | | |
229 | 536M | prevector& operator=(const prevector<N, T, Size, Diff>& other) { |
230 | 536M | if (&other == this) { |
231 | 0 | return *this; |
232 | 0 | } |
233 | 536M | assign(other.begin(), other.end()); |
234 | 536M | return *this; |
235 | 536M | } prevector<16u, unsigned char, unsigned int, int>::operator=(prevector<16u, unsigned char, unsigned int, int> const&) Line | Count | Source | 229 | 273M | prevector& operator=(const prevector<N, T, Size, Diff>& other) { | 230 | 273M | if (&other == this) { | 231 | 0 | return *this; | 232 | 0 | } | 233 | 273M | assign(other.begin(), other.end()); | 234 | 273M | return *this; | 235 | 273M | } |
prevector<36u, unsigned char, unsigned int, int>::operator=(prevector<36u, unsigned char, unsigned int, int> const&) Line | Count | Source | 229 | 263M | prevector& operator=(const prevector<N, T, Size, Diff>& other) { | 230 | 263M | if (&other == this) { | 231 | 0 | return *this; | 232 | 0 | } | 233 | 263M | assign(other.begin(), other.end()); | 234 | 263M | return *this; | 235 | 263M | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::operator=(prevector<8u, int, unsigned int, int> const&) |
236 | | |
237 | 143M | prevector& operator=(prevector<N, T, Size, Diff>&& other) noexcept { |
238 | 143M | if (!is_direct()) { |
239 | 0 | free(_union.indirect_contents.indirect); |
240 | 0 | } |
241 | 143M | _union = std::move(other._union); |
242 | 143M | _size = other._size; |
243 | 143M | other._size = 0; |
244 | 143M | return *this; |
245 | 143M | } prevector<16u, unsigned char, unsigned int, int>::operator=(prevector<16u, unsigned char, unsigned int, int>&&) Line | Count | Source | 237 | 756k | prevector& operator=(prevector<N, T, Size, Diff>&& other) noexcept { | 238 | 756k | if (!is_direct()) { | 239 | 0 | free(_union.indirect_contents.indirect); | 240 | 0 | } | 241 | 756k | _union = std::move(other._union); | 242 | 756k | _size = other._size; | 243 | 756k | other._size = 0; | 244 | 756k | return *this; | 245 | 756k | } |
prevector<36u, unsigned char, unsigned int, int>::operator=(prevector<36u, unsigned char, unsigned int, int>&&) Line | Count | Source | 237 | 142M | prevector& operator=(prevector<N, T, Size, Diff>&& other) noexcept { | 238 | 142M | if (!is_direct()) { | 239 | 0 | free(_union.indirect_contents.indirect); | 240 | 0 | } | 241 | 142M | _union = std::move(other._union); | 242 | 142M | _size = other._size; | 243 | 142M | other._size = 0; | 244 | 142M | return *this; | 245 | 142M | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::operator=(prevector<8u, int, unsigned int, int>&&) |
246 | | |
247 | 16.7G | size_type size() const { |
248 | 16.7G | return is_direct() ? _size13.8G : _size - N - 12.87G ; |
249 | 16.7G | } prevector<36u, unsigned char, unsigned int, int>::size() const Line | Count | Source | 247 | 14.3G | size_type size() const { | 248 | 14.3G | return is_direct() ? _size11.4G : _size - N - 12.84G ; | 249 | 14.3G | } |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::size() const prevector<16u, unsigned char, unsigned int, int>::size() const Line | Count | Source | 247 | 2.37G | size_type size() const { | 248 | 2.37G | return is_direct() ? _size2.35G : _size - N - 122.7M ; | 249 | 2.37G | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::size() const prevector<35u, unsigned char, unsigned int, int>::size() const Line | Count | Source | 247 | 6.38k | size_type size() const { | 248 | 6.38k | return is_direct() ? _size : _size - N - 10 ; | 249 | 6.38k | } |
Unexecuted instantiation: prevector<4u, Network, unsigned int, int>::size() const |
250 | | |
251 | 2.24G | bool empty() const { |
252 | 2.24G | return size() == 0; |
253 | 2.24G | } prevector<36u, unsigned char, unsigned int, int>::empty() const Line | Count | Source | 251 | 2.24G | bool empty() const { | 252 | 2.24G | return size() == 0; | 253 | 2.24G | } |
Unexecuted instantiation: prevector<16u, unsigned char, unsigned int, int>::empty() const Unexecuted instantiation: prevector<8u, int, unsigned int, int>::empty() const Unexecuted instantiation: prevector<4u, Network, unsigned int, int>::empty() const |
254 | | |
255 | 282M | iterator begin() { return iterator(item_ptr(0)); }Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::begin() prevector<36u, unsigned char, unsigned int, int>::begin() Line | Count | Source | 255 | 282M | iterator begin() { return iterator(item_ptr(0)); } |
Unexecuted instantiation: prevector<16u, unsigned char, unsigned int, int>::begin() Unexecuted instantiation: prevector<8u, int, unsigned int, int>::begin() prevector<35u, unsigned char, unsigned int, int>::begin() Line | Count | Source | 255 | 1.82k | iterator begin() { return iterator(item_ptr(0)); } |
|
256 | 3.24G | const_iterator begin() const { return const_iterator(item_ptr(0)); }prevector<36u, unsigned char, unsigned int, int>::begin() const Line | Count | Source | 256 | 1.86G | const_iterator begin() const { return const_iterator(item_ptr(0)); } |
prevector<16u, unsigned char, unsigned int, int>::begin() const Line | Count | Source | 256 | 1.37G | const_iterator begin() const { return const_iterator(item_ptr(0)); } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::begin() const |
257 | 854M | iterator end() { return iterator(item_ptr(size())); }prevector<36u, unsigned char, unsigned int, int>::end() Line | Count | Source | 257 | 305M | iterator end() { return iterator(item_ptr(size())); } |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::end() prevector<16u, unsigned char, unsigned int, int>::end() Line | Count | Source | 257 | 549M | iterator end() { return iterator(item_ptr(size())); } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::end() prevector<35u, unsigned char, unsigned int, int>::end() Line | Count | Source | 257 | 1.82k | iterator end() { return iterator(item_ptr(size())); } |
|
258 | 3.88G | const_iterator end() const { return const_iterator(item_ptr(size())); }prevector<36u, unsigned char, unsigned int, int>::end() const Line | Count | Source | 258 | 3.46G | const_iterator end() const { return const_iterator(item_ptr(size())); } |
prevector<16u, unsigned char, unsigned int, int>::end() const Line | Count | Source | 258 | 419M | const_iterator end() const { return const_iterator(item_ptr(size())); } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::end() const |
259 | | |
260 | 833M | size_t capacity() const { |
261 | 833M | if (is_direct()) { |
262 | 833M | return N; |
263 | 833M | } else { |
264 | 0 | return _union.indirect_contents.capacity; |
265 | 0 | } |
266 | 833M | } prevector<36u, unsigned char, unsigned int, int>::capacity() const Line | Count | Source | 260 | 559M | size_t capacity() const { | 261 | 559M | if (is_direct()) { | 262 | 559M | return N; | 263 | 559M | } else { | 264 | 0 | return _union.indirect_contents.capacity; | 265 | 0 | } | 266 | 559M | } |
prevector<16u, unsigned char, unsigned int, int>::capacity() const Line | Count | Source | 260 | 274M | size_t capacity() const { | 261 | 274M | if (is_direct()) { | 262 | 274M | return N; | 263 | 274M | } else { | 264 | 0 | return _union.indirect_contents.capacity; | 265 | 0 | } | 266 | 274M | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::capacity() const Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::capacity() const prevector<35u, unsigned char, unsigned int, int>::capacity() const Line | Count | Source | 260 | 1.82k | size_t capacity() const { | 261 | 1.82k | if (is_direct()) { | 262 | 1.82k | return N; | 263 | 1.82k | } else { | 264 | 0 | return _union.indirect_contents.capacity; | 265 | 0 | } | 266 | 1.82k | } |
Unexecuted instantiation: prevector<4u, Network, unsigned int, int>::capacity() const |
267 | | |
268 | 287M | T& operator[](size_type pos) { |
269 | 287M | return *item_ptr(pos); |
270 | 287M | } prevector<36u, unsigned char, unsigned int, int>::operator[](unsigned int) Line | Count | Source | 268 | 287M | T& operator[](size_type pos) { | 269 | 287M | return *item_ptr(pos); | 270 | 287M | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::operator[](unsigned int) Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::operator[](unsigned int) Unexecuted instantiation: prevector<16u, unsigned char, unsigned int, int>::operator[](unsigned int) Unexecuted instantiation: prevector<4u, Network, unsigned int, int>::operator[](unsigned int) |
271 | | |
272 | 1.97G | const T& operator[](size_type pos) const { |
273 | 1.97G | return *item_ptr(pos); |
274 | 1.97G | } prevector<36u, unsigned char, unsigned int, int>::operator[](unsigned int) const Line | Count | Source | 272 | 690M | const T& operator[](size_type pos) const { | 273 | 690M | return *item_ptr(pos); | 274 | 690M | } |
prevector<16u, unsigned char, unsigned int, int>::operator[](unsigned int) const Line | Count | Source | 272 | 1.28G | const T& operator[](size_type pos) const { | 273 | 1.28G | return *item_ptr(pos); | 274 | 1.28G | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::operator[](unsigned int) const |
275 | | |
276 | 1.24G | void resize(size_type new_size) { |
277 | 1.24G | size_type cur_size = size(); |
278 | 1.24G | if (cur_size == new_size) { |
279 | 924M | return; |
280 | 924M | } |
281 | 323M | if (cur_size > new_size) { |
282 | 286M | erase(item_ptr(new_size), end()); |
283 | 286M | return; |
284 | 286M | } |
285 | 36.9M | if (new_size > capacity()) { |
286 | 36.9M | change_capacity(new_size); |
287 | 36.9M | } |
288 | 36.9M | ptrdiff_t increase = new_size - cur_size; |
289 | 36.9M | fill(item_ptr(cur_size), increase); |
290 | 36.9M | _size += increase; |
291 | 36.9M | } prevector<36u, unsigned char, unsigned int, int>::resize(unsigned int) Line | Count | Source | 276 | 972M | void resize(size_type new_size) { | 277 | 972M | size_type cur_size = size(); | 278 | 972M | if (cur_size == new_size) { | 279 | 923M | return; | 280 | 923M | } | 281 | 48.3M | if (cur_size > new_size) { | 282 | 11.4M | erase(item_ptr(new_size), end()); | 283 | 11.4M | return; | 284 | 11.4M | } | 285 | 36.8M | if (new_size > capacity()) { | 286 | 36.8M | change_capacity(new_size); | 287 | 36.8M | } | 288 | 36.8M | ptrdiff_t increase = new_size - cur_size; | 289 | 36.8M | fill(item_ptr(cur_size), increase); | 290 | 36.8M | _size += increase; | 291 | 36.8M | } |
prevector<16u, unsigned char, unsigned int, int>::resize(unsigned int) Line | Count | Source | 276 | 275M | void resize(size_type new_size) { | 277 | 275M | size_type cur_size = size(); | 278 | 275M | if (cur_size == new_size) { | 279 | 343k | return; | 280 | 343k | } | 281 | 275M | if (cur_size > new_size) { | 282 | 274M | erase(item_ptr(new_size), end()); | 283 | 274M | return; | 284 | 274M | } | 285 | 137k | if (new_size > capacity()) { | 286 | 137k | change_capacity(new_size); | 287 | 137k | } | 288 | 137k | ptrdiff_t increase = new_size - cur_size; | 289 | 137k | fill(item_ptr(cur_size), increase); | 290 | 137k | _size += increase; | 291 | 137k | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::resize(unsigned int) Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::resize(unsigned int) |
292 | | |
293 | 0 | void reserve(size_type new_capacity) { |
294 | 0 | if (new_capacity > capacity()) { |
295 | 0 | change_capacity(new_capacity); |
296 | 0 | } |
297 | 0 | } Unexecuted instantiation: prevector<36u, unsigned char, unsigned int, int>::reserve(unsigned int) Unexecuted instantiation: prevector<8u, int, unsigned int, int>::reserve(unsigned int) |
298 | | |
299 | 624M | void shrink_to_fit() { |
300 | 624M | change_capacity(size()); |
301 | 624M | } prevector<36u, unsigned char, unsigned int, int>::shrink_to_fit() Line | Count | Source | 299 | 624M | void shrink_to_fit() { | 300 | 624M | change_capacity(size()); | 301 | 624M | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::shrink_to_fit() |
302 | | |
303 | 1.20G | void clear() { |
304 | 1.20G | resize(0); |
305 | 1.20G | } prevector<36u, unsigned char, unsigned int, int>::clear() Line | Count | Source | 303 | 935M | void clear() { | 304 | 935M | resize(0); | 305 | 935M | } |
prevector<16u, unsigned char, unsigned int, int>::clear() Line | Count | Source | 303 | 274M | void clear() { | 304 | 274M | resize(0); | 305 | 274M | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::clear() Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::clear() |
306 | | |
307 | 133M | iterator insert(iterator pos, const T& value) { |
308 | 133M | size_type p = pos - begin(); |
309 | 133M | size_type new_size = size() + 1; |
310 | 133M | if (capacity() < new_size) { |
311 | 0 | change_capacity(new_size + (new_size >> 1)); |
312 | 0 | } |
313 | 133M | T* ptr = item_ptr(p); |
314 | 133M | T* dst = ptr + 1; |
315 | 133M | memmove(dst, ptr, (size() - p) * sizeof(T)); |
316 | 133M | _size++; |
317 | 133M | new(static_cast<void*>(ptr)) T(value); |
318 | 133M | return iterator(ptr); |
319 | 133M | } prevector<36u, unsigned char, unsigned int, int>::insert(prevector<36u, unsigned char, unsigned int, int>::iterator, unsigned char const&) Line | Count | Source | 307 | 133M | iterator insert(iterator pos, const T& value) { | 308 | 133M | size_type p = pos - begin(); | 309 | 133M | size_type new_size = size() + 1; | 310 | 133M | if (capacity() < new_size) { | 311 | 0 | change_capacity(new_size + (new_size >> 1)); | 312 | 0 | } | 313 | 133M | T* ptr = item_ptr(p); | 314 | 133M | T* dst = ptr + 1; | 315 | 133M | memmove(dst, ptr, (size() - p) * sizeof(T)); | 316 | 133M | _size++; | 317 | 133M | new(static_cast<void*>(ptr)) T(value); | 318 | 133M | return iterator(ptr); | 319 | 133M | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::insert(prevector<8u, int, unsigned int, int>::iterator, int const&) |
320 | | |
321 | 0 | void insert(iterator pos, size_type count, const T& value) { |
322 | 0 | size_type p = pos - begin(); |
323 | 0 | size_type new_size = size() + count; |
324 | 0 | if (capacity() < new_size) { |
325 | 0 | change_capacity(new_size + (new_size >> 1)); |
326 | 0 | } |
327 | 0 | T* ptr = item_ptr(p); |
328 | 0 | T* dst = ptr + count; |
329 | 0 | memmove(dst, ptr, (size() - p) * sizeof(T)); |
330 | 0 | _size += count; |
331 | 0 | fill(item_ptr(p), count, value); |
332 | 0 | } Unexecuted instantiation: prevector<8u, int, unsigned int, int>::insert(prevector<8u, int, unsigned int, int>::iterator, unsigned int, int const&) Unexecuted instantiation: prevector<36u, unsigned char, unsigned int, int>::insert(prevector<36u, unsigned char, unsigned int, int>::iterator, unsigned int, unsigned char const&) |
333 | | |
334 | | template <std::input_iterator InputIterator> |
335 | 89.2M | void insert(iterator pos, InputIterator first, InputIterator last) { |
336 | 89.2M | size_type p = pos - begin(); |
337 | 89.2M | difference_type count = last - first; |
338 | 89.2M | size_type new_size = size() + count; |
339 | 89.2M | if (capacity() < new_size) { |
340 | 0 | change_capacity(new_size + (new_size >> 1)); |
341 | 0 | } |
342 | 89.2M | T* ptr = item_ptr(p); |
343 | 89.2M | T* dst = ptr + count; |
344 | 89.2M | memmove(dst, ptr, (size() - p) * sizeof(T)); |
345 | 89.2M | _size += count; |
346 | 89.2M | fill(ptr, first, last); |
347 | 89.2M | } Unexecuted instantiation: void prevector<36u, unsigned char, unsigned int, int>::insert<unsigned char const*>(prevector<36u, unsigned char, unsigned int, int>::iterator, unsigned char const*, unsigned char const*) void prevector<36u, unsigned char, unsigned int, int>::insert<__gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>>(prevector<36u, unsigned char, unsigned int, int>::iterator, __gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::span<unsigned char const, 18446744073709551615ul>>) Line | Count | Source | 335 | 89.2M | void insert(iterator pos, InputIterator first, InputIterator last) { | 336 | 89.2M | size_type p = pos - begin(); | 337 | 89.2M | difference_type count = last - first; | 338 | 89.2M | size_type new_size = size() + count; | 339 | 89.2M | if (capacity() < new_size) { | 340 | 0 | change_capacity(new_size + (new_size >> 1)); | 341 | 0 | } | 342 | 89.2M | T* ptr = item_ptr(p); | 343 | 89.2M | T* dst = ptr + count; | 344 | 89.2M | memmove(dst, ptr, (size() - p) * sizeof(T)); | 345 | 89.2M | _size += count; | 346 | 89.2M | fill(ptr, first, last); | 347 | 89.2M | } |
Unexecuted instantiation: void prevector<36u, unsigned char, unsigned int, int>::insert<prevector<36u, unsigned char, unsigned int, int>::iterator>(prevector<36u, unsigned char, unsigned int, int>::iterator, prevector<36u, unsigned char, unsigned int, int>::iterator, prevector<36u, unsigned char, unsigned int, int>::iterator) Unexecuted instantiation: void prevector<8u, int, unsigned int, int>::insert<int*>(prevector<8u, int, unsigned int, int>::iterator, int*, int*) Unexecuted instantiation: void prevector<36u, unsigned char, unsigned int, int>::insert<__gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>>(prevector<36u, unsigned char, unsigned int, int>::iterator, __gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>, __gnu_cxx::__normal_iterator<unsigned char*, std::vector<unsigned char, std::allocator<unsigned char>>>) void prevector<35u, unsigned char, unsigned int, int>::insert<unsigned char*>(prevector<35u, unsigned char, unsigned int, int>::iterator, unsigned char*, unsigned char*) Line | Count | Source | 335 | 912 | void insert(iterator pos, InputIterator first, InputIterator last) { | 336 | 912 | size_type p = pos - begin(); | 337 | 912 | difference_type count = last - first; | 338 | 912 | size_type new_size = size() + count; | 339 | 912 | if (capacity() < new_size) { | 340 | 0 | change_capacity(new_size + (new_size >> 1)); | 341 | 0 | } | 342 | 912 | T* ptr = item_ptr(p); | 343 | 912 | T* dst = ptr + count; | 344 | 912 | memmove(dst, ptr, (size() - p) * sizeof(T)); | 345 | 912 | _size += count; | 346 | 912 | fill(ptr, first, last); | 347 | 912 | } |
void prevector<35u, unsigned char, unsigned int, int>::insert<unsigned char const*>(prevector<35u, unsigned char, unsigned int, int>::iterator, unsigned char const*, unsigned char const*) Line | Count | Source | 335 | 912 | void insert(iterator pos, InputIterator first, InputIterator last) { | 336 | 912 | size_type p = pos - begin(); | 337 | 912 | difference_type count = last - first; | 338 | 912 | size_type new_size = size() + count; | 339 | 912 | if (capacity() < new_size) { | 340 | 0 | change_capacity(new_size + (new_size >> 1)); | 341 | 0 | } | 342 | 912 | T* ptr = item_ptr(p); | 343 | 912 | T* dst = ptr + count; | 344 | 912 | memmove(dst, ptr, (size() - p) * sizeof(T)); | 345 | 912 | _size += count; | 346 | 912 | fill(ptr, first, last); | 347 | 912 | } |
Unexecuted instantiation: void prevector<36u, unsigned char, unsigned int, int>::insert<prevector<36u, unsigned char, unsigned int, int>::const_iterator>(prevector<36u, unsigned char, unsigned int, int>::iterator, prevector<36u, unsigned char, unsigned int, int>::const_iterator, prevector<36u, unsigned char, unsigned int, int>::const_iterator) |
348 | | |
349 | 29.0M | inline void resize_uninitialized(size_type new_size) { |
350 | | // resize_uninitialized changes the size of the prevector but does not initialize it. |
351 | | // If size < new_size, the added elements must be initialized explicitly. |
352 | 29.0M | if (capacity() < new_size) { |
353 | 3.90M | change_capacity(new_size); |
354 | 3.90M | _size += new_size - size(); |
355 | 3.90M | return; |
356 | 3.90M | } |
357 | 25.1M | if (new_size < size()) { |
358 | 0 | erase(item_ptr(new_size), end()); |
359 | 25.1M | } else { |
360 | 25.1M | _size += new_size - size(); |
361 | 25.1M | } |
362 | 25.1M | } prevector<36u, unsigned char, unsigned int, int>::resize_uninitialized(unsigned int) Line | Count | Source | 349 | 29.0M | inline void resize_uninitialized(size_type new_size) { | 350 | | // resize_uninitialized changes the size of the prevector but does not initialize it. | 351 | | // If size < new_size, the added elements must be initialized explicitly. | 352 | 29.0M | if (capacity() < new_size) { | 353 | 3.90M | change_capacity(new_size); | 354 | 3.90M | _size += new_size - size(); | 355 | 3.90M | return; | 356 | 3.90M | } | 357 | 25.1M | if (new_size < size()) { | 358 | 0 | erase(item_ptr(new_size), end()); | 359 | 25.1M | } else { | 360 | 25.1M | _size += new_size - size(); | 361 | 25.1M | } | 362 | 25.1M | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::resize_uninitialized(unsigned int) |
363 | | |
364 | 0 | iterator erase(iterator pos) { |
365 | 0 | return erase(pos, pos + 1); |
366 | 0 | } Unexecuted instantiation: prevector<8u, int, unsigned int, int>::erase(prevector<8u, int, unsigned int, int>::iterator) Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::erase(prevector<33u, unsigned char, unsigned int, int>::iterator) |
367 | | |
368 | 286M | iterator erase(iterator first, iterator last) { |
369 | | // Erase is not allowed to the change the object's capacity. That means |
370 | | // that when starting with an indirectly allocated prevector with |
371 | | // size and capacity > N, the result may be a still indirectly allocated |
372 | | // prevector with size <= N and capacity > N. A shrink_to_fit() call is |
373 | | // necessary to switch to the (more efficient) directly allocated |
374 | | // representation (with capacity N and size <= N). |
375 | 286M | iterator p = first; |
376 | 286M | char* endp = (char*)&(*end()); |
377 | 286M | _size -= last - p; |
378 | 286M | memmove(&(*first), &(*last), endp - ((char*)(&(*last)))); |
379 | 286M | return first; |
380 | 286M | } prevector<36u, unsigned char, unsigned int, int>::erase(prevector<36u, unsigned char, unsigned int, int>::iterator, prevector<36u, unsigned char, unsigned int, int>::iterator) Line | Count | Source | 368 | 11.4M | iterator erase(iterator first, iterator last) { | 369 | | // Erase is not allowed to the change the object's capacity. That means | 370 | | // that when starting with an indirectly allocated prevector with | 371 | | // size and capacity > N, the result may be a still indirectly allocated | 372 | | // prevector with size <= N and capacity > N. A shrink_to_fit() call is | 373 | | // necessary to switch to the (more efficient) directly allocated | 374 | | // representation (with capacity N and size <= N). | 375 | 11.4M | iterator p = first; | 376 | 11.4M | char* endp = (char*)&(*end()); | 377 | 11.4M | _size -= last - p; | 378 | 11.4M | memmove(&(*first), &(*last), endp - ((char*)(&(*last)))); | 379 | 11.4M | return first; | 380 | 11.4M | } |
prevector<16u, unsigned char, unsigned int, int>::erase(prevector<16u, unsigned char, unsigned int, int>::iterator, prevector<16u, unsigned char, unsigned int, int>::iterator) Line | Count | Source | 368 | 274M | iterator erase(iterator first, iterator last) { | 369 | | // Erase is not allowed to the change the object's capacity. That means | 370 | | // that when starting with an indirectly allocated prevector with | 371 | | // size and capacity > N, the result may be a still indirectly allocated | 372 | | // prevector with size <= N and capacity > N. A shrink_to_fit() call is | 373 | | // necessary to switch to the (more efficient) directly allocated | 374 | | // representation (with capacity N and size <= N). | 375 | 274M | iterator p = first; | 376 | 274M | char* endp = (char*)&(*end()); | 377 | 274M | _size -= last - p; | 378 | 274M | memmove(&(*first), &(*last), endp - ((char*)(&(*last)))); | 379 | 274M | return first; | 380 | 274M | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::erase(prevector<8u, int, unsigned int, int>::iterator, prevector<8u, int, unsigned int, int>::iterator) Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::erase(prevector<33u, unsigned char, unsigned int, int>::iterator, prevector<33u, unsigned char, unsigned int, int>::iterator) |
381 | | |
382 | | template<typename... Args> |
383 | 7.08M | void emplace_back(Args&&... args) { |
384 | 7.08M | size_type new_size = size() + 1; |
385 | 7.08M | if (capacity() < new_size) { |
386 | 0 | change_capacity(new_size + (new_size >> 1)); |
387 | 0 | } |
388 | 7.08M | new(item_ptr(size())) T(std::forward<Args>(args)...); |
389 | 7.08M | _size++; |
390 | 7.08M | } void prevector<36u, unsigned char, unsigned int, int>::emplace_back<unsigned char const&>(unsigned char const&) Line | Count | Source | 383 | 7.08M | void emplace_back(Args&&... args) { | 384 | 7.08M | size_type new_size = size() + 1; | 385 | 7.08M | if (capacity() < new_size) { | 386 | 0 | change_capacity(new_size + (new_size >> 1)); | 387 | 0 | } | 388 | 7.08M | new(item_ptr(size())) T(std::forward<Args>(args)...); | 389 | 7.08M | _size++; | 390 | 7.08M | } |
Unexecuted instantiation: void prevector<8u, int, unsigned int, int>::emplace_back<int const&>(int const&) Unexecuted instantiation: void prevector<4u, Network, unsigned int, int>::emplace_back<Network const&>(Network const&) |
391 | | |
392 | 7.08M | void push_back(const T& value) { |
393 | 7.08M | emplace_back(value); |
394 | 7.08M | } prevector<36u, unsigned char, unsigned int, int>::push_back(unsigned char const&) Line | Count | Source | 392 | 7.08M | void push_back(const T& value) { | 393 | 7.08M | emplace_back(value); | 394 | 7.08M | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::push_back(int const&) Unexecuted instantiation: prevector<4u, Network, unsigned int, int>::push_back(Network const&) |
395 | | |
396 | 0 | void pop_back() { |
397 | 0 | erase(end() - 1, end()); |
398 | 0 | } |
399 | | |
400 | | T& front() { |
401 | | return *item_ptr(0); |
402 | | } |
403 | | |
404 | | const T& front() const { |
405 | | return *item_ptr(0); |
406 | | } |
407 | | |
408 | 0 | T& back() { |
409 | 0 | return *item_ptr(size() - 1); |
410 | 0 | } |
411 | | |
412 | 0 | const T& back() const { |
413 | 0 | return *item_ptr(size() - 1); |
414 | 0 | } |
415 | | |
416 | | void swap(prevector<N, T, Size, Diff>& other) noexcept |
417 | 0 | { |
418 | 0 | std::swap(_union, other._union); |
419 | 0 | std::swap(_size, other._size); |
420 | 0 | } |
421 | | |
422 | 2.41G | ~prevector() { |
423 | 2.41G | if (!is_direct()) { |
424 | 225M | free(_union.indirect_contents.indirect); |
425 | 225M | _union.indirect_contents.indirect = nullptr; |
426 | 225M | } |
427 | 2.41G | } prevector<16u, unsigned char, unsigned int, int>::~prevector() Line | Count | Source | 422 | 424M | ~prevector() { | 423 | 424M | if (!is_direct()) { | 424 | 22.3M | free(_union.indirect_contents.indirect); | 425 | 22.3M | _union.indirect_contents.indirect = nullptr; | 426 | 22.3M | } | 427 | 424M | } |
prevector<36u, unsigned char, unsigned int, int>::~prevector() Line | Count | Source | 422 | 1.99G | ~prevector() { | 423 | 1.99G | if (!is_direct()) { | 424 | 203M | free(_union.indirect_contents.indirect); | 425 | 203M | _union.indirect_contents.indirect = nullptr; | 426 | 203M | } | 427 | 1.99G | } |
prevector<33u, unsigned char, unsigned int, int>::~prevector() Line | Count | Source | 422 | 350k | ~prevector() { | 423 | 350k | if (!is_direct()) { | 424 | 0 | free(_union.indirect_contents.indirect); | 425 | 0 | _union.indirect_contents.indirect = nullptr; | 426 | 0 | } | 427 | 350k | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::~prevector() prevector<35u, unsigned char, unsigned int, int>::~prevector() Line | Count | Source | 422 | 912 | ~prevector() { | 423 | 912 | if (!is_direct()) { | 424 | 0 | free(_union.indirect_contents.indirect); | 425 | 0 | _union.indirect_contents.indirect = nullptr; | 426 | 0 | } | 427 | 912 | } |
Unexecuted instantiation: prevector<4u, Network, unsigned int, int>::~prevector() |
428 | | |
429 | 1.85M | constexpr bool operator==(const prevector& other) const { |
430 | 1.85M | return std::ranges::equal(*this, other); |
431 | 1.85M | } prevector<36u, unsigned char, unsigned int, int>::operator==(prevector<36u, unsigned char, unsigned int, int> const&) const Line | Count | Source | 429 | 1.12M | constexpr bool operator==(const prevector& other) const { | 430 | 1.12M | return std::ranges::equal(*this, other); | 431 | 1.12M | } |
Unexecuted instantiation: prevector<8u, int, unsigned int, int>::operator==(prevector<8u, int, unsigned int, int> const&) const prevector<16u, unsigned char, unsigned int, int>::operator==(prevector<16u, unsigned char, unsigned int, int> const&) const Line | Count | Source | 429 | 735k | constexpr bool operator==(const prevector& other) const { | 430 | 735k | return std::ranges::equal(*this, other); | 431 | 735k | } |
|
432 | | |
433 | 0 | bool operator<(const prevector<N, T, Size, Diff>& other) const { |
434 | 0 | if (size() < other.size()) { |
435 | 0 | return true; |
436 | 0 | } |
437 | 0 | if (size() > other.size()) { |
438 | 0 | return false; |
439 | 0 | } |
440 | 0 | const_iterator b1 = begin(); |
441 | 0 | const_iterator b2 = other.begin(); |
442 | 0 | const_iterator e1 = end(); |
443 | 0 | while (b1 != e1) { |
444 | 0 | if ((*b1) < (*b2)) { |
445 | 0 | return true; |
446 | 0 | } |
447 | 0 | if ((*b2) < (*b1)) { |
448 | 0 | return false; |
449 | 0 | } |
450 | 0 | ++b1; |
451 | 0 | ++b2; |
452 | 0 | } |
453 | 0 | return false; |
454 | 0 | } Unexecuted instantiation: prevector<36u, unsigned char, unsigned int, int>::operator<(prevector<36u, unsigned char, unsigned int, int> const&) const Unexecuted instantiation: prevector<16u, unsigned char, unsigned int, int>::operator<(prevector<16u, unsigned char, unsigned int, int> const&) const |
455 | | |
456 | 224M | size_t allocated_memory() const { |
457 | 224M | if (is_direct()) { |
458 | 224M | return 0; |
459 | 224M | } else { |
460 | 30.2k | return ((size_t)(sizeof(T))) * _union.indirect_contents.capacity; |
461 | 30.2k | } |
462 | 224M | } |
463 | | |
464 | 3.10M | value_type* data() { |
465 | 3.10M | return item_ptr(0); |
466 | 3.10M | } Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::data() prevector<36u, unsigned char, unsigned int, int>::data() Line | Count | Source | 464 | 2.10M | value_type* data() { | 465 | 2.10M | return item_ptr(0); | 466 | 2.10M | } |
prevector<16u, unsigned char, unsigned int, int>::data() Line | Count | Source | 464 | 997k | value_type* data() { | 465 | 997k | return item_ptr(0); | 466 | 997k | } |
prevector<35u, unsigned char, unsigned int, int>::data() Line | Count | Source | 464 | 912 | value_type* data() { | 465 | 912 | return item_ptr(0); | 466 | 912 | } |
|
467 | | |
468 | 2.41G | const value_type* data() const { |
469 | 2.41G | return item_ptr(0); |
470 | 2.41G | } prevector<36u, unsigned char, unsigned int, int>::data() const Line | Count | Source | 468 | 1.97G | const value_type* data() const { | 469 | 1.97G | return item_ptr(0); | 470 | 1.97G | } |
prevector<16u, unsigned char, unsigned int, int>::data() const Line | Count | Source | 468 | 447M | const value_type* data() const { | 469 | 447M | return item_ptr(0); | 470 | 447M | } |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::data() const |
471 | | }; |
472 | | |
473 | | #endif // BITCOIN_PREVECTOR_H |