/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 | 0 | iterator(T* ptr_) : ptr(ptr_) {} Unexecuted instantiation: _ZN9prevectorILj16EhjiE8iteratorC2EPh Unexecuted instantiation: _ZN9prevectorILj36EhjiE8iteratorC2EPh Unexecuted instantiation: _ZN9prevectorILj8EijiE8iteratorC2EPi Unexecuted instantiation: _ZN9prevectorILj33EhjiE8iteratorC2EPh Unexecuted instantiation: _ZN9prevectorILj35EhjiE8iteratorC2EPh |
61 | 0 | T& operator*() const { return *ptr; } Unexecuted instantiation: _ZNK9prevectorILj36EhjiE8iteratordeEv Unexecuted instantiation: _ZNK9prevectorILj16EhjiE8iteratordeEv Unexecuted instantiation: _ZNK9prevectorILj8EijiE8iteratordeEv Unexecuted instantiation: _ZNK9prevectorILj33EhjiE8iteratordeEv Unexecuted instantiation: _ZNK9prevectorILj35EhjiE8iteratordeEv |
62 | 0 | T* operator->() const { return ptr; } Unexecuted instantiation: _ZNK9prevectorILj33EhjiE8iteratorptEv Unexecuted instantiation: _ZNK9prevectorILj36EhjiE8iteratorptEv Unexecuted instantiation: _ZNK9prevectorILj16EhjiE8iteratorptEv Unexecuted instantiation: _ZNK9prevectorILj35EhjiE8iteratorptEv |
63 | | T& operator[](size_type pos) const { return ptr[pos]; } |
64 | 0 | 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 | 0 | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } Unexecuted instantiation: _ZmiN9prevectorILj36EhjiE8iteratorES1_ Unexecuted instantiation: _ZmiN9prevectorILj16EhjiE8iteratorES1_ Unexecuted instantiation: _ZmiN9prevectorILj8EijiE8iteratorES1_ Unexecuted instantiation: _ZmiN9prevectorILj33EhjiE8iteratorES1_ Unexecuted instantiation: _ZmiN9prevectorILj35EhjiE8iteratorES1_ |
69 | 0 | iterator operator+(size_type n) const { return iterator(ptr + n); } Unexecuted instantiation: _ZNK9prevectorILj36EhjiE8iteratorplEj Unexecuted instantiation: _ZNK9prevectorILj8EijiE8iteratorplEj Unexecuted instantiation: _ZNK9prevectorILj33EhjiE8iteratorplEj |
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 | | bool operator==(iterator x) const { return ptr == x.ptr; } |
75 | 0 | bool operator!=(iterator x) const { return ptr != x.ptr; } |
76 | | bool operator>=(iterator x) const { return ptr >= x.ptr; } |
77 | | bool operator<=(iterator x) const { return ptr <= x.ptr; } |
78 | | bool operator>(iterator x) const { return ptr > x.ptr; } |
79 | | bool operator<(iterator x) const { return ptr < x.ptr; } |
80 | | }; |
81 | | |
82 | | class const_iterator { |
83 | | const T* ptr{}; |
84 | | public: |
85 | | typedef Diff difference_type; |
86 | | typedef const T* pointer; |
87 | | typedef const T& reference; |
88 | | using element_type = const T; |
89 | | using iterator_category = std::contiguous_iterator_tag; |
90 | | const_iterator() = default; |
91 | 1.25G | const_iterator(const T* ptr_) : ptr(ptr_) {} Unexecuted instantiation: _ZN9prevectorILj16EhjiE14const_iteratorC2EPKh _ZN9prevectorILj36EhjiE14const_iteratorC2EPKh Line | Count | Source | 91 | 1.25G | const_iterator(const T* ptr_) : ptr(ptr_) {} |
Unexecuted instantiation: _ZN9prevectorILj8EijiE14const_iteratorC2EPKi |
92 | 0 | const_iterator(iterator x) : ptr(&(*x)) {} |
93 | 21.4G | const T& operator*() const { return *ptr; } _ZNK9prevectorILj36EhjiE14const_iteratordeEv Line | Count | Source | 93 | 21.4G | const T& operator*() const { return *ptr; } |
Unexecuted instantiation: _ZNK9prevectorILj16EhjiE14const_iteratordeEv Unexecuted instantiation: _ZNK9prevectorILj8EijiE14const_iteratordeEv |
94 | 0 | const T* operator->() const { return ptr; } Unexecuted instantiation: _ZNK9prevectorILj36EhjiE14const_iteratorptEv Unexecuted instantiation: _ZNK9prevectorILj16EhjiE14const_iteratorptEv |
95 | 0 | const T& operator[](size_type pos) const { return ptr[pos]; } Unexecuted instantiation: _ZNK9prevectorILj8EijiE14const_iteratorixEj Unexecuted instantiation: _ZNK9prevectorILj36EhjiE14const_iteratorixEj |
96 | 21.0G | const_iterator& operator++() { ptr++; return *this; } _ZN9prevectorILj36EhjiE14const_iteratorppEv Line | Count | Source | 96 | 21.0G | const_iterator& operator++() { ptr++; return *this; } |
Unexecuted instantiation: _ZN9prevectorILj16EhjiE14const_iteratorppEv Unexecuted instantiation: _ZN9prevectorILj8EijiE14const_iteratorppEv |
97 | 0 | const_iterator& operator--() { ptr--; return *this; } Unexecuted instantiation: _ZN9prevectorILj8EijiE14const_iteratormmEv Unexecuted instantiation: _ZN9prevectorILj36EhjiE14const_iteratormmEv |
98 | 0 | const_iterator operator++(int) { const_iterator copy(*this); ++(*this); return copy; } |
99 | | const_iterator operator--(int) { const_iterator copy(*this); --(*this); return copy; } |
100 | 211M | difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); } Unexecuted instantiation: _ZmiN9prevectorILj16EhjiE14const_iteratorES1_ _ZmiN9prevectorILj36EhjiE14const_iteratorES1_ Line | Count | Source | 100 | 211M | difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); } |
Unexecuted instantiation: _ZmiN9prevectorILj8EijiE14const_iteratorES1_ |
101 | 0 | const_iterator operator+(size_type n) const { return const_iterator(ptr + n); } Unexecuted instantiation: _ZNK9prevectorILj8EijiE14const_iteratorplEj Unexecuted instantiation: _ZNK9prevectorILj36EhjiE14const_iteratorplEj |
102 | | const_iterator friend operator+(size_type n, const_iterator x) { return x + n; } |
103 | 0 | const_iterator& operator+=(size_type n) { ptr += n; return *this; } |
104 | 0 | const_iterator operator-(size_type n) const { return const_iterator(ptr - n); } Unexecuted instantiation: _ZNK9prevectorILj8EijiE14const_iteratormiEj Unexecuted instantiation: _ZNK9prevectorILj36EhjiE14const_iteratormiEj |
105 | | const_iterator& operator-=(size_type n) { ptr -= n; return *this; } |
106 | 0 | bool operator==(const_iterator x) const { return ptr == x.ptr; } Unexecuted instantiation: _ZNK9prevectorILj8EijiE14const_iteratoreqES1_ Unexecuted instantiation: _ZNK9prevectorILj16EhjiE14const_iteratoreqES1_ Unexecuted instantiation: _ZNK9prevectorILj36EhjiE14const_iteratoreqES1_ |
107 | 21.6G | bool operator!=(const_iterator x) const { return ptr != x.ptr; } _ZNK9prevectorILj36EhjiE14const_iteratorneES1_ Line | Count | Source | 107 | 21.6G | bool operator!=(const_iterator x) const { return ptr != x.ptr; } |
Unexecuted instantiation: _ZNK9prevectorILj16EhjiE14const_iteratorneES1_ Unexecuted instantiation: _ZNK9prevectorILj8EijiE14const_iteratorneES1_ |
108 | 0 | bool operator>=(const_iterator x) const { return ptr >= x.ptr; } |
109 | | bool operator<=(const_iterator x) const { return ptr <= x.ptr; } |
110 | | bool operator>(const_iterator x) const { return ptr > x.ptr; } |
111 | 0 | bool operator<(const_iterator x) const { return ptr < x.ptr; } |
112 | | }; |
113 | | |
114 | | private: |
115 | | #pragma pack(push, 1) |
116 | | union direct_or_indirect { |
117 | | char direct[sizeof(T) * N]; |
118 | | struct { |
119 | | char* indirect; |
120 | | size_type capacity; |
121 | | } indirect_contents; |
122 | | }; |
123 | | #pragma pack(pop) |
124 | | alignas(char*) direct_or_indirect _union = {}; |
125 | | size_type _size = 0; |
126 | | |
127 | | static_assert(alignof(char*) % alignof(size_type) == 0 && sizeof(char*) % alignof(size_type) == 0, "size_type cannot have more restrictive alignment requirement than pointer"); |
128 | | static_assert(alignof(char*) % alignof(T) == 0, "value_type T cannot have more restrictive alignment requirement than pointer"); |
129 | | |
130 | 629M | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } _ZN9prevectorILj36EhjiE10direct_ptrEi Line | Count | Source | 130 | 629M | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } |
Unexecuted instantiation: _ZN9prevectorILj33EhjiE10direct_ptrEi Unexecuted instantiation: _ZN9prevectorILj16EhjiE10direct_ptrEi Unexecuted instantiation: _ZN9prevectorILj8EijiE10direct_ptrEi Unexecuted instantiation: _ZN9prevectorILj35EhjiE10direct_ptrEi |
131 | 1.90G | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } _ZNK9prevectorILj36EhjiE10direct_ptrEi Line | Count | Source | 131 | 1.90G | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } |
Unexecuted instantiation: _ZNK9prevectorILj16EhjiE10direct_ptrEi Unexecuted instantiation: _ZNK9prevectorILj8EijiE10direct_ptrEi Unexecuted instantiation: _ZNK9prevectorILj33EhjiE10direct_ptrEi |
132 | 0 | T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect_contents.indirect) + pos; } Unexecuted instantiation: _ZN9prevectorILj36EhjiE12indirect_ptrEi Unexecuted instantiation: _ZN9prevectorILj33EhjiE12indirect_ptrEi Unexecuted instantiation: _ZN9prevectorILj16EhjiE12indirect_ptrEi Unexecuted instantiation: _ZN9prevectorILj8EijiE12indirect_ptrEi Unexecuted instantiation: _ZN9prevectorILj35EhjiE12indirect_ptrEi |
133 | 0 | const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect_contents.indirect) + pos; } Unexecuted instantiation: _ZNK9prevectorILj36EhjiE12indirect_ptrEi Unexecuted instantiation: _ZNK9prevectorILj16EhjiE12indirect_ptrEi Unexecuted instantiation: _ZNK9prevectorILj8EijiE12indirect_ptrEi Unexecuted instantiation: _ZNK9prevectorILj33EhjiE12indirect_ptrEi |
134 | 7.29G | bool is_direct() const { return _size <= N; } _ZNK9prevectorILj36EhjiE9is_directEv Line | Count | Source | 134 | 7.29G | bool is_direct() const { return _size <= N; } |
Unexecuted instantiation: _ZNK9prevectorILj33EhjiE9is_directEv Unexecuted instantiation: _ZNK9prevectorILj16EhjiE9is_directEv Unexecuted instantiation: _ZNK9prevectorILj8EijiE9is_directEv Unexecuted instantiation: _ZNK9prevectorILj35EhjiE9is_directEv |
135 | | |
136 | 418M | void change_capacity(size_type new_capacity) { |
137 | 418M | if (new_capacity <= N) { |
138 | 418M | if (!is_direct()) { |
139 | 0 | T* indirect = indirect_ptr(0); |
140 | 0 | T* src = indirect; |
141 | 0 | T* dst = direct_ptr(0); |
142 | 0 | memcpy(dst, src, size() * sizeof(T)); |
143 | 0 | free(indirect); |
144 | 0 | _size -= N + 1; |
145 | 0 | } |
146 | 418M | } else { |
147 | 0 | if (!is_direct()) { |
148 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert |
149 | | success. These should instead use an allocator or new/delete so that handlers |
150 | | are called as necessary, but performance would be slightly degraded by doing so. */ |
151 | 0 | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); |
152 | 0 | assert(_union.indirect_contents.indirect); |
153 | 0 | _union.indirect_contents.capacity = new_capacity; |
154 | 0 | } else { |
155 | 0 | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); |
156 | 0 | assert(new_indirect); |
157 | 0 | T* src = direct_ptr(0); |
158 | 0 | T* dst = reinterpret_cast<T*>(new_indirect); |
159 | 0 | memcpy(dst, src, size() * sizeof(T)); |
160 | 0 | _union.indirect_contents.indirect = new_indirect; |
161 | 0 | _union.indirect_contents.capacity = new_capacity; |
162 | 0 | _size += N + 1; |
163 | 0 | } |
164 | 0 | } |
165 | 418M | } _ZN9prevectorILj36EhjiE15change_capacityEj Line | Count | Source | 136 | 418M | void change_capacity(size_type new_capacity) { | 137 | 418M | if (new_capacity <= N) { | 138 | 418M | if (!is_direct()) { | 139 | 0 | T* indirect = indirect_ptr(0); | 140 | 0 | T* src = indirect; | 141 | 0 | T* dst = direct_ptr(0); | 142 | 0 | memcpy(dst, src, size() * sizeof(T)); | 143 | 0 | free(indirect); | 144 | 0 | _size -= N + 1; | 145 | 0 | } | 146 | 418M | } else { | 147 | 0 | if (!is_direct()) { | 148 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert | 149 | | success. These should instead use an allocator or new/delete so that handlers | 150 | | are called as necessary, but performance would be slightly degraded by doing so. */ | 151 | 0 | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); | 152 | 0 | assert(_union.indirect_contents.indirect); | 153 | 0 | _union.indirect_contents.capacity = new_capacity; | 154 | 0 | } else { | 155 | 0 | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); | 156 | 0 | assert(new_indirect); | 157 | 0 | T* src = direct_ptr(0); | 158 | 0 | T* dst = reinterpret_cast<T*>(new_indirect); | 159 | 0 | memcpy(dst, src, size() * sizeof(T)); | 160 | 0 | _union.indirect_contents.indirect = new_indirect; | 161 | 0 | _union.indirect_contents.capacity = new_capacity; | 162 | 0 | _size += N + 1; | 163 | 0 | } | 164 | 0 | } | 165 | 418M | } |
Unexecuted instantiation: _ZN9prevectorILj16EhjiE15change_capacityEj Unexecuted instantiation: _ZN9prevectorILj33EhjiE15change_capacityEj Unexecuted instantiation: _ZN9prevectorILj8EijiE15change_capacityEj Unexecuted instantiation: _ZN9prevectorILj35EhjiE15change_capacityEj |
166 | | |
167 | 629M | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } _ZN9prevectorILj36EhjiE8item_ptrEi Line | Count | Source | 167 | 629M | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } |
Unexecuted instantiation: _ZN9prevectorILj33EhjiE8item_ptrEi Unexecuted instantiation: _ZN9prevectorILj16EhjiE8item_ptrEi Unexecuted instantiation: _ZN9prevectorILj8EijiE8item_ptrEi Unexecuted instantiation: _ZN9prevectorILj35EhjiE8item_ptrEi |
168 | 1.90G | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } _ZNK9prevectorILj36EhjiE8item_ptrEi Line | Count | Source | 168 | 1.90G | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } |
Unexecuted instantiation: _ZNK9prevectorILj16EhjiE8item_ptrEi Unexecuted instantiation: _ZNK9prevectorILj8EijiE8item_ptrEi Unexecuted instantiation: _ZNK9prevectorILj33EhjiE8item_ptrEi |
169 | | |
170 | 0 | void fill(T* dst, ptrdiff_t count, const T& value = T{}) { |
171 | 0 | std::fill_n(dst, count, value); |
172 | 0 | } Unexecuted instantiation: _ZN9prevectorILj36EhjiE4fillEPhlRKh Unexecuted instantiation: _ZN9prevectorILj16EhjiE4fillEPhlRKh Unexecuted instantiation: _ZN9prevectorILj33EhjiE4fillEPhlRKh Unexecuted instantiation: _ZN9prevectorILj8EijiE4fillEPilRKi |
173 | | |
174 | | template <std::input_iterator InputIterator> |
175 | 629M | void fill(T* dst, InputIterator first, InputIterator last) { |
176 | 21.6G | while (first != last) { |
177 | 21.0G | new(static_cast<void*>(dst)) T(*first); |
178 | 21.0G | ++dst; |
179 | 21.0G | ++first; |
180 | 21.0G | } |
181 | 629M | } Unexecuted instantiation: _ZN9prevectorILj36EhjiE4fillITkSt14input_iteratorPKhEEvPhT_S5_ Unexecuted instantiation: _ZN9prevectorILj36EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvPhT_SA_ _ZN9prevectorILj36EhjiE4fillITkSt14input_iteratorNS0_14const_iteratorEEEvPhT_S4_ Line | Count | Source | 175 | 629M | void fill(T* dst, InputIterator first, InputIterator last) { | 176 | 21.6G | while (first != last) { | 177 | 21.0G | new(static_cast<void*>(dst)) T(*first); | 178 | 21.0G | ++dst; | 179 | 21.0G | ++first; | 180 | 21.0G | } | 181 | 629M | } |
Unexecuted instantiation: _ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorNS0_14const_iteratorEEEvPhT_S4_ Unexecuted instantiation: _ZN9prevectorILj36EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt6vectorIhSaIhEEEEEEvPhT_SB_ Unexecuted instantiation: _ZN9prevectorILj36EhjiE4fillITkSt14input_iteratorNS0_8iteratorEEEvPhT_S4_ Unexecuted instantiation: _ZN9prevectorILj8EijiE4fillITkSt14input_iteratorPiEEvS2_T_S3_ Unexecuted instantiation: _ZN9prevectorILj8EijiE4fillITkSt14input_iteratorNS0_14const_iteratorEEEvPiT_S4_ Unexecuted instantiation: _ZN9prevectorILj8EijiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEEEEvPiT_SB_ Unexecuted instantiation: _ZN9prevectorILj33EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt6vectorIhSaIhEEEEEEvPhT_SB_ Unexecuted instantiation: _ZN9prevectorILj36EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEEvS4_T_S9_ Unexecuted instantiation: _ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvPhT_SA_ Unexecuted instantiation: _ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorPhEEvS2_T_S3_ Unexecuted instantiation: _ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEEvS4_T_S9_ Unexecuted instantiation: _ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorPKhEEvPhT_S5_ Unexecuted instantiation: _ZN9prevectorILj35EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvPhT_SA_ Unexecuted instantiation: _ZN9prevectorILj35EhjiE4fillITkSt14input_iteratorPhEEvS2_T_S3_ Unexecuted instantiation: _ZN9prevectorILj35EhjiE4fillITkSt14input_iteratorPKhEEvPhT_S5_ |
182 | | |
183 | | public: |
184 | 0 | void assign(size_type n, const T& val) { |
185 | 0 | clear(); |
186 | 0 | if (capacity() < n) { |
187 | 0 | change_capacity(n); |
188 | 0 | } |
189 | 0 | _size += n; |
190 | 0 | fill(item_ptr(0), n, val); |
191 | 0 | } Unexecuted instantiation: _ZN9prevectorILj16EhjiE6assignEjRKh Unexecuted instantiation: _ZN9prevectorILj8EijiE6assignEjRKi |
192 | | |
193 | | template <std::input_iterator InputIterator> |
194 | 211M | void assign(InputIterator first, InputIterator last) { |
195 | 211M | size_type n = last - first; |
196 | 211M | clear(); |
197 | 211M | if (capacity() < n) { |
198 | 0 | change_capacity(n); |
199 | 0 | } |
200 | 211M | _size += n; |
201 | 211M | fill(item_ptr(0), first, last); |
202 | 211M | } Unexecuted instantiation: _ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorNS0_14const_iteratorEEEvT_S3_ _ZN9prevectorILj36EhjiE6assignITkSt14input_iteratorNS0_14const_iteratorEEEvT_S3_ Line | Count | Source | 194 | 211M | void assign(InputIterator first, InputIterator last) { | 195 | 211M | size_type n = last - first; | 196 | 211M | clear(); | 197 | 211M | if (capacity() < n) { | 198 | 0 | change_capacity(n); | 199 | 0 | } | 200 | 211M | _size += n; | 201 | 211M | fill(item_ptr(0), first, last); | 202 | 211M | } |
Unexecuted instantiation: _ZN9prevectorILj8EijiE6assignITkSt14input_iteratorNS0_14const_iteratorEEEvT_S3_ Unexecuted instantiation: _ZN9prevectorILj33EhjiE6assignITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt6vectorIhSaIhEEEEEEvT_SA_ Unexecuted instantiation: _ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvT_S9_ Unexecuted instantiation: _ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorPhEEvT_S3_ Unexecuted instantiation: _ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEEvT_S9_ Unexecuted instantiation: _ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorPKhEEvT_S4_ |
203 | | |
204 | 216M | prevector() = default; _ZN9prevectorILj36EhjiEC2Ev Line | Count | Source | 204 | 216M | prevector() = default; |
Unexecuted instantiation: _ZN9prevectorILj33EhjiEC2Ev Unexecuted instantiation: _ZN9prevectorILj8EijiEC2Ev |
205 | | |
206 | | explicit prevector(size_type n) { |
207 | | resize(n); |
208 | | } |
209 | | |
210 | 0 | explicit prevector(size_type n, const T& val) { |
211 | 0 | change_capacity(n); |
212 | 0 | _size += n; |
213 | 0 | fill(item_ptr(0), n, val); |
214 | 0 | } Unexecuted instantiation: _ZN9prevectorILj33EhjiEC2EjRKh Unexecuted instantiation: _ZN9prevectorILj16EhjiEC2EjRKh |
215 | | |
216 | | template <std::input_iterator InputIterator> |
217 | 0 | prevector(InputIterator first, InputIterator last) { |
218 | 0 | size_type n = last - first; |
219 | 0 | change_capacity(n); |
220 | 0 | _size += n; |
221 | 0 | fill(item_ptr(0), first, last); |
222 | 0 | } Unexecuted instantiation: _ZN9prevectorILj36EhjiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt6vectorIhSaIhEEEEEET_SA_ Unexecuted instantiation: _ZN9prevectorILj8EijiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEEEET_SA_ Unexecuted instantiation: _ZN9prevectorILj8EijiEC2ITkSt14input_iteratorNS0_14const_iteratorEEET_S3_ Unexecuted instantiation: _ZN9prevectorILj36EhjiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEET_S9_ Unexecuted instantiation: _ZN9prevectorILj35EhjiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEET_S9_ Unexecuted instantiation: _ZN9prevectorILj36EhjiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEET_S9_ Unexecuted instantiation: _ZN9prevectorILj36EhjiEC2ITkSt14input_iteratorNS0_14const_iteratorEEET_S3_ |
223 | | |
224 | 418M | prevector(const prevector<N, T, Size, Diff>& other) { |
225 | 418M | size_type n = other.size(); |
226 | 418M | change_capacity(n); |
227 | 418M | _size += n; |
228 | 418M | fill(item_ptr(0), other.begin(), other.end()); |
229 | 418M | } Unexecuted instantiation: _ZN9prevectorILj16EhjiEC2ERKS0_ _ZN9prevectorILj36EhjiEC2ERKS0_ Line | Count | Source | 224 | 418M | prevector(const prevector<N, T, Size, Diff>& other) { | 225 | 418M | size_type n = other.size(); | 226 | 418M | change_capacity(n); | 227 | 418M | _size += n; | 228 | 418M | fill(item_ptr(0), other.begin(), other.end()); | 229 | 418M | } |
|
230 | | |
231 | | prevector(prevector<N, T, Size, Diff>&& other) noexcept |
232 | 281M | : _union(std::move(other._union)), _size(other._size) |
233 | 281M | { |
234 | 281M | other._size = 0; |
235 | 281M | } Unexecuted instantiation: _ZN9prevectorILj16EhjiEC2EOS0_ _ZN9prevectorILj36EhjiEC2EOS0_ Line | Count | Source | 232 | 281M | : _union(std::move(other._union)), _size(other._size) | 233 | 281M | { | 234 | 281M | other._size = 0; | 235 | 281M | } |
|
236 | | |
237 | 211M | prevector& operator=(const prevector<N, T, Size, Diff>& other) { |
238 | 211M | if (&other == this) { |
239 | 0 | return *this; |
240 | 0 | } |
241 | 211M | assign(other.begin(), other.end()); |
242 | 211M | return *this; |
243 | 211M | } Unexecuted instantiation: _ZN9prevectorILj16EhjiEaSERKS0_ _ZN9prevectorILj36EhjiEaSERKS0_ Line | Count | Source | 237 | 211M | prevector& operator=(const prevector<N, T, Size, Diff>& other) { | 238 | 211M | if (&other == this) { | 239 | 0 | return *this; | 240 | 0 | } | 241 | 211M | assign(other.begin(), other.end()); | 242 | 211M | return *this; | 243 | 211M | } |
Unexecuted instantiation: _ZN9prevectorILj8EijiEaSERKS0_ |
244 | | |
245 | 0 | prevector& operator=(prevector<N, T, Size, Diff>&& other) noexcept { |
246 | 0 | if (!is_direct()) { |
247 | 0 | free(_union.indirect_contents.indirect); |
248 | 0 | } |
249 | 0 | _union = std::move(other._union); |
250 | 0 | _size = other._size; |
251 | 0 | other._size = 0; |
252 | 0 | return *this; |
253 | 0 | } Unexecuted instantiation: _ZN9prevectorILj16EhjiEaSEOS0_ Unexecuted instantiation: _ZN9prevectorILj36EhjiEaSEOS0_ Unexecuted instantiation: _ZN9prevectorILj8EijiEaSEOS0_ |
254 | | |
255 | 3.21G | size_type size() const { |
256 | 3.21G | return is_direct() ? _size : _size - N - 1; |
257 | 3.21G | } _ZNK9prevectorILj36EhjiE4sizeEv Line | Count | Source | 255 | 3.21G | size_type size() const { | 256 | 3.21G | return is_direct() ? _size : _size - N - 1; | 257 | 3.21G | } |
Unexecuted instantiation: _ZNK9prevectorILj33EhjiE4sizeEv Unexecuted instantiation: _ZNK9prevectorILj16EhjiE4sizeEv Unexecuted instantiation: _ZNK9prevectorILj8EijiE4sizeEv Unexecuted instantiation: _ZNK9prevectorILj35EhjiE4sizeEv |
258 | | |
259 | 658M | bool empty() const { |
260 | 658M | return size() == 0; |
261 | 658M | } _ZNK9prevectorILj36EhjiE5emptyEv Line | Count | Source | 259 | 658M | bool empty() const { | 260 | 658M | return size() == 0; | 261 | 658M | } |
Unexecuted instantiation: _ZNK9prevectorILj16EhjiE5emptyEv Unexecuted instantiation: _ZNK9prevectorILj8EijiE5emptyEv |
262 | | |
263 | 0 | iterator begin() { return iterator(item_ptr(0)); } Unexecuted instantiation: _ZN9prevectorILj33EhjiE5beginEv Unexecuted instantiation: _ZN9prevectorILj36EhjiE5beginEv Unexecuted instantiation: _ZN9prevectorILj16EhjiE5beginEv Unexecuted instantiation: _ZN9prevectorILj8EijiE5beginEv Unexecuted instantiation: _ZN9prevectorILj35EhjiE5beginEv |
264 | 629M | const_iterator begin() const { return const_iterator(item_ptr(0)); } _ZNK9prevectorILj36EhjiE5beginEv Line | Count | Source | 264 | 629M | const_iterator begin() const { return const_iterator(item_ptr(0)); } |
Unexecuted instantiation: _ZNK9prevectorILj16EhjiE5beginEv Unexecuted instantiation: _ZNK9prevectorILj8EijiE5beginEv |
265 | 0 | iterator end() { return iterator(item_ptr(size())); } Unexecuted instantiation: _ZN9prevectorILj36EhjiE3endEv Unexecuted instantiation: _ZN9prevectorILj33EhjiE3endEv Unexecuted instantiation: _ZN9prevectorILj16EhjiE3endEv Unexecuted instantiation: _ZN9prevectorILj8EijiE3endEv Unexecuted instantiation: _ZN9prevectorILj35EhjiE3endEv |
266 | 629M | const_iterator end() const { return const_iterator(item_ptr(size())); } _ZNK9prevectorILj36EhjiE3endEv Line | Count | Source | 266 | 629M | const_iterator end() const { return const_iterator(item_ptr(size())); } |
Unexecuted instantiation: _ZNK9prevectorILj16EhjiE3endEv Unexecuted instantiation: _ZNK9prevectorILj8EijiE3endEv |
267 | | |
268 | 211M | size_t capacity() const { |
269 | 211M | if (is_direct()) { |
270 | 211M | return N; |
271 | 211M | } else { |
272 | 0 | return _union.indirect_contents.capacity; |
273 | 0 | } |
274 | 211M | } _ZNK9prevectorILj36EhjiE8capacityEv Line | Count | Source | 268 | 211M | size_t capacity() const { | 269 | 211M | if (is_direct()) { | 270 | 211M | return N; | 271 | 211M | } else { | 272 | 0 | return _union.indirect_contents.capacity; | 273 | 0 | } | 274 | 211M | } |
Unexecuted instantiation: _ZNK9prevectorILj16EhjiE8capacityEv Unexecuted instantiation: _ZNK9prevectorILj8EijiE8capacityEv Unexecuted instantiation: _ZNK9prevectorILj33EhjiE8capacityEv Unexecuted instantiation: _ZNK9prevectorILj35EhjiE8capacityEv |
275 | | |
276 | 0 | T& operator[](size_type pos) { |
277 | 0 | return *item_ptr(pos); |
278 | 0 | } Unexecuted instantiation: _ZN9prevectorILj36EhjiEixEj Unexecuted instantiation: _ZN9prevectorILj8EijiEixEj Unexecuted instantiation: _ZN9prevectorILj33EhjiEixEj Unexecuted instantiation: _ZN9prevectorILj16EhjiEixEj |
279 | | |
280 | 0 | const T& operator[](size_type pos) const { |
281 | 0 | return *item_ptr(pos); |
282 | 0 | } Unexecuted instantiation: _ZNK9prevectorILj16EhjiEixEj Unexecuted instantiation: _ZNK9prevectorILj36EhjiEixEj Unexecuted instantiation: _ZNK9prevectorILj8EijiEixEj |
283 | | |
284 | 211M | void resize(size_type new_size) { |
285 | 211M | size_type cur_size = size(); |
286 | 211M | if (cur_size == new_size) { |
287 | 211M | return; |
288 | 211M | } |
289 | 0 | if (cur_size > new_size) { |
290 | 0 | erase(item_ptr(new_size), end()); |
291 | 0 | return; |
292 | 0 | } |
293 | 0 | if (new_size > capacity()) { |
294 | 0 | change_capacity(new_size); |
295 | 0 | } |
296 | 0 | ptrdiff_t increase = new_size - cur_size; |
297 | 0 | fill(item_ptr(cur_size), increase); |
298 | 0 | _size += increase; |
299 | 0 | } _ZN9prevectorILj36EhjiE6resizeEj Line | Count | Source | 284 | 211M | void resize(size_type new_size) { | 285 | 211M | size_type cur_size = size(); | 286 | 211M | if (cur_size == new_size) { | 287 | 211M | return; | 288 | 211M | } | 289 | 0 | if (cur_size > new_size) { | 290 | 0 | erase(item_ptr(new_size), end()); | 291 | 0 | return; | 292 | 0 | } | 293 | 0 | if (new_size > capacity()) { | 294 | 0 | change_capacity(new_size); | 295 | 0 | } | 296 | 0 | ptrdiff_t increase = new_size - cur_size; | 297 | 0 | fill(item_ptr(cur_size), increase); | 298 | 0 | _size += increase; | 299 | 0 | } |
Unexecuted instantiation: _ZN9prevectorILj16EhjiE6resizeEj Unexecuted instantiation: _ZN9prevectorILj8EijiE6resizeEj Unexecuted instantiation: _ZN9prevectorILj33EhjiE6resizeEj |
300 | | |
301 | 0 | void reserve(size_type new_capacity) { |
302 | 0 | if (new_capacity > capacity()) { |
303 | 0 | change_capacity(new_capacity); |
304 | 0 | } |
305 | 0 | } Unexecuted instantiation: _ZN9prevectorILj36EhjiE7reserveEj Unexecuted instantiation: _ZN9prevectorILj8EijiE7reserveEj |
306 | | |
307 | 0 | void shrink_to_fit() { |
308 | 0 | change_capacity(size()); |
309 | 0 | } Unexecuted instantiation: _ZN9prevectorILj36EhjiE13shrink_to_fitEv Unexecuted instantiation: _ZN9prevectorILj8EijiE13shrink_to_fitEv |
310 | | |
311 | 211M | void clear() { |
312 | 211M | resize(0); |
313 | 211M | } _ZN9prevectorILj36EhjiE5clearEv Line | Count | Source | 311 | 211M | void clear() { | 312 | 211M | resize(0); | 313 | 211M | } |
Unexecuted instantiation: _ZN9prevectorILj16EhjiE5clearEv Unexecuted instantiation: _ZN9prevectorILj8EijiE5clearEv Unexecuted instantiation: _ZN9prevectorILj33EhjiE5clearEv |
314 | | |
315 | 0 | iterator insert(iterator pos, const T& value) { |
316 | 0 | size_type p = pos - begin(); |
317 | 0 | size_type new_size = size() + 1; |
318 | 0 | if (capacity() < new_size) { |
319 | 0 | change_capacity(new_size + (new_size >> 1)); |
320 | 0 | } |
321 | 0 | T* ptr = item_ptr(p); |
322 | 0 | T* dst = ptr + 1; |
323 | 0 | memmove(dst, ptr, (size() - p) * sizeof(T)); |
324 | 0 | _size++; |
325 | 0 | new(static_cast<void*>(ptr)) T(value); |
326 | 0 | return iterator(ptr); |
327 | 0 | } Unexecuted instantiation: _ZN9prevectorILj36EhjiE6insertENS0_8iteratorERKh Unexecuted instantiation: _ZN9prevectorILj8EijiE6insertENS0_8iteratorERKi |
328 | | |
329 | 0 | void insert(iterator pos, size_type count, const T& value) { |
330 | 0 | size_type p = pos - begin(); |
331 | 0 | size_type new_size = size() + count; |
332 | 0 | if (capacity() < new_size) { |
333 | 0 | change_capacity(new_size + (new_size >> 1)); |
334 | 0 | } |
335 | 0 | T* ptr = item_ptr(p); |
336 | 0 | T* dst = ptr + count; |
337 | 0 | memmove(dst, ptr, (size() - p) * sizeof(T)); |
338 | 0 | _size += count; |
339 | 0 | fill(item_ptr(p), count, value); |
340 | 0 | } Unexecuted instantiation: _ZN9prevectorILj8EijiE6insertENS0_8iteratorEjRKi Unexecuted instantiation: _ZN9prevectorILj36EhjiE6insertENS0_8iteratorEjRKh |
341 | | |
342 | | template <std::input_iterator InputIterator> |
343 | 0 | void insert(iterator pos, InputIterator first, InputIterator last) { |
344 | 0 | size_type p = pos - begin(); |
345 | 0 | difference_type count = last - first; |
346 | 0 | size_type new_size = size() + count; |
347 | 0 | if (capacity() < new_size) { |
348 | 0 | change_capacity(new_size + (new_size >> 1)); |
349 | 0 | } |
350 | 0 | T* ptr = item_ptr(p); |
351 | 0 | T* dst = ptr + count; |
352 | 0 | memmove(dst, ptr, (size() - p) * sizeof(T)); |
353 | 0 | _size += count; |
354 | 0 | fill(ptr, first, last); |
355 | 0 | } Unexecuted instantiation: _ZN9prevectorILj36EhjiE6insertITkSt14input_iteratorPKhEEvNS0_8iteratorET_S5_ Unexecuted instantiation: _ZN9prevectorILj36EhjiE6insertITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvNS0_8iteratorET_SA_ Unexecuted instantiation: _ZN9prevectorILj36EhjiE6insertITkSt14input_iteratorNS0_8iteratorEEEvS2_T_S3_ Unexecuted instantiation: _ZN9prevectorILj8EijiE6insertITkSt14input_iteratorPiEEvNS0_8iteratorET_S4_ Unexecuted instantiation: _ZN9prevectorILj36EhjiE6insertITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEEvNS0_8iteratorET_SA_ Unexecuted instantiation: _ZN9prevectorILj35EhjiE6insertITkSt14input_iteratorPhEEvNS0_8iteratorET_S4_ Unexecuted instantiation: _ZN9prevectorILj35EhjiE6insertITkSt14input_iteratorPKhEEvNS0_8iteratorET_S5_ Unexecuted instantiation: _ZN9prevectorILj36EhjiE6insertITkSt14input_iteratorNS0_14const_iteratorEEEvNS0_8iteratorET_S4_ |
356 | | |
357 | 0 | inline void resize_uninitialized(size_type new_size) { |
358 | | // resize_uninitialized changes the size of the prevector but does not initialize it. |
359 | | // If size < new_size, the added elements must be initialized explicitly. |
360 | 0 | if (capacity() < new_size) { |
361 | 0 | change_capacity(new_size); |
362 | 0 | _size += new_size - size(); |
363 | 0 | return; |
364 | 0 | } |
365 | 0 | if (new_size < size()) { |
366 | 0 | erase(item_ptr(new_size), end()); |
367 | 0 | } else { |
368 | 0 | _size += new_size - size(); |
369 | 0 | } |
370 | 0 | } Unexecuted instantiation: _ZN9prevectorILj36EhjiE20resize_uninitializedEj Unexecuted instantiation: _ZN9prevectorILj8EijiE20resize_uninitializedEj |
371 | | |
372 | 0 | iterator erase(iterator pos) { |
373 | 0 | return erase(pos, pos + 1); |
374 | 0 | } Unexecuted instantiation: _ZN9prevectorILj8EijiE5eraseENS0_8iteratorE Unexecuted instantiation: _ZN9prevectorILj33EhjiE5eraseENS0_8iteratorE |
375 | | |
376 | 0 | iterator erase(iterator first, iterator last) { |
377 | | // Erase is not allowed to the change the object's capacity. That means |
378 | | // that when starting with an indirectly allocated prevector with |
379 | | // size and capacity > N, the result may be a still indirectly allocated |
380 | | // prevector with size <= N and capacity > N. A shrink_to_fit() call is |
381 | | // necessary to switch to the (more efficient) directly allocated |
382 | | // representation (with capacity N and size <= N). |
383 | 0 | iterator p = first; |
384 | 0 | char* endp = (char*)&(*end()); |
385 | 0 | _size -= last - p; |
386 | 0 | memmove(&(*first), &(*last), endp - ((char*)(&(*last)))); |
387 | 0 | return first; |
388 | 0 | } Unexecuted instantiation: _ZN9prevectorILj36EhjiE5eraseENS0_8iteratorES1_ Unexecuted instantiation: _ZN9prevectorILj16EhjiE5eraseENS0_8iteratorES1_ Unexecuted instantiation: _ZN9prevectorILj8EijiE5eraseENS0_8iteratorES1_ Unexecuted instantiation: _ZN9prevectorILj33EhjiE5eraseENS0_8iteratorES1_ |
389 | | |
390 | | template<typename... Args> |
391 | 0 | void emplace_back(Args&&... args) { |
392 | 0 | size_type new_size = size() + 1; |
393 | 0 | if (capacity() < new_size) { |
394 | 0 | change_capacity(new_size + (new_size >> 1)); |
395 | 0 | } |
396 | 0 | new(item_ptr(size())) T(std::forward<Args>(args)...); |
397 | 0 | _size++; |
398 | 0 | } Unexecuted instantiation: _ZN9prevectorILj36EhjiE12emplace_backIJRKhEEEvDpOT_ Unexecuted instantiation: _ZN9prevectorILj8EijiE12emplace_backIJRKiEEEvDpOT_ |
399 | | |
400 | 0 | void push_back(const T& value) { |
401 | 0 | emplace_back(value); |
402 | 0 | } Unexecuted instantiation: _ZN9prevectorILj36EhjiE9push_backERKh Unexecuted instantiation: _ZN9prevectorILj8EijiE9push_backERKi |
403 | | |
404 | 0 | void pop_back() { |
405 | 0 | erase(end() - 1, end()); |
406 | 0 | } |
407 | | |
408 | | T& front() { |
409 | | return *item_ptr(0); |
410 | | } |
411 | | |
412 | | const T& front() const { |
413 | | return *item_ptr(0); |
414 | | } |
415 | | |
416 | 0 | T& back() { |
417 | 0 | return *item_ptr(size() - 1); |
418 | 0 | } |
419 | | |
420 | 0 | const T& back() const { |
421 | 0 | return *item_ptr(size() - 1); |
422 | 0 | } |
423 | | |
424 | | void swap(prevector<N, T, Size, Diff>& other) noexcept |
425 | 0 | { |
426 | 0 | std::swap(_union, other._union); |
427 | 0 | std::swap(_size, other._size); |
428 | 0 | } |
429 | | |
430 | 916M | ~prevector() { |
431 | 916M | if (!is_direct()) { |
432 | 0 | free(_union.indirect_contents.indirect); |
433 | 0 | _union.indirect_contents.indirect = nullptr; |
434 | 0 | } |
435 | 916M | } Unexecuted instantiation: _ZN9prevectorILj16EhjiED2Ev _ZN9prevectorILj36EhjiED2Ev Line | Count | Source | 430 | 916M | ~prevector() { | 431 | 916M | if (!is_direct()) { | 432 | 0 | free(_union.indirect_contents.indirect); | 433 | 0 | _union.indirect_contents.indirect = nullptr; | 434 | 0 | } | 435 | 916M | } |
Unexecuted instantiation: _ZN9prevectorILj33EhjiED2Ev Unexecuted instantiation: _ZN9prevectorILj8EijiED2Ev Unexecuted instantiation: _ZN9prevectorILj35EhjiED2Ev |
436 | | |
437 | 0 | bool operator==(const prevector<N, T, Size, Diff>& other) const { |
438 | 0 | if (other.size() != size()) { |
439 | 0 | return false; |
440 | 0 | } |
441 | 0 | const_iterator b1 = begin(); |
442 | 0 | const_iterator b2 = other.begin(); |
443 | 0 | const_iterator e1 = end(); |
444 | 0 | while (b1 != e1) { |
445 | 0 | if ((*b1) != (*b2)) { |
446 | 0 | return false; |
447 | 0 | } |
448 | 0 | ++b1; |
449 | 0 | ++b2; |
450 | 0 | } |
451 | 0 | return true; |
452 | 0 | } Unexecuted instantiation: _ZNK9prevectorILj36EhjiEeqERKS0_ Unexecuted instantiation: _ZNK9prevectorILj8EijiEeqERKS0_ Unexecuted instantiation: _ZNK9prevectorILj16EhjiEeqERKS0_ |
453 | | |
454 | 0 | bool operator!=(const prevector<N, T, Size, Diff>& other) const { |
455 | 0 | return !(*this == other); |
456 | 0 | } |
457 | | |
458 | 0 | bool operator<(const prevector<N, T, Size, Diff>& other) const { |
459 | 0 | if (size() < other.size()) { |
460 | 0 | return true; |
461 | 0 | } |
462 | 0 | if (size() > other.size()) { |
463 | 0 | return false; |
464 | 0 | } |
465 | 0 | const_iterator b1 = begin(); |
466 | 0 | const_iterator b2 = other.begin(); |
467 | 0 | const_iterator e1 = end(); |
468 | 0 | while (b1 != e1) { |
469 | 0 | if ((*b1) < (*b2)) { |
470 | 0 | return true; |
471 | 0 | } |
472 | 0 | if ((*b2) < (*b1)) { |
473 | 0 | return false; |
474 | 0 | } |
475 | 0 | ++b1; |
476 | 0 | ++b2; |
477 | 0 | } |
478 | 0 | return false; |
479 | 0 | } Unexecuted instantiation: _ZNK9prevectorILj36EhjiEltERKS0_ Unexecuted instantiation: _ZNK9prevectorILj16EhjiEltERKS0_ |
480 | | |
481 | 0 | size_t allocated_memory() const { |
482 | 0 | if (is_direct()) { |
483 | 0 | return 0; |
484 | 0 | } else { |
485 | 0 | return ((size_t)(sizeof(T))) * _union.indirect_contents.capacity; |
486 | 0 | } |
487 | 0 | } |
488 | | |
489 | 0 | value_type* data() { |
490 | 0 | return item_ptr(0); |
491 | 0 | } Unexecuted instantiation: _ZN9prevectorILj33EhjiE4dataEv Unexecuted instantiation: _ZN9prevectorILj36EhjiE4dataEv Unexecuted instantiation: _ZN9prevectorILj16EhjiE4dataEv Unexecuted instantiation: _ZN9prevectorILj35EhjiE4dataEv |
492 | | |
493 | 642M | const value_type* data() const { |
494 | 642M | return item_ptr(0); |
495 | 642M | } _ZNK9prevectorILj36EhjiE4dataEv Line | Count | Source | 493 | 642M | const value_type* data() const { | 494 | 642M | return item_ptr(0); | 495 | 642M | } |
Unexecuted instantiation: _ZNK9prevectorILj16EhjiE4dataEv Unexecuted instantiation: _ZNK9prevectorILj33EhjiE4dataEv |
496 | | }; |
497 | | |
498 | | #endif // BITCOIN_PREVECTOR_H |