/root/bitcoin/src/prevector.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) 2015-2022 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 | | typedef Size size_type; |
42 | | typedef Diff difference_type; |
43 | | typedef T value_type; |
44 | | typedef value_type& reference; |
45 | | typedef const value_type& const_reference; |
46 | | typedef value_type* pointer; |
47 | | typedef const value_type* const_pointer; |
48 | | |
49 | | class iterator { |
50 | | T* ptr{}; |
51 | | public: |
52 | | typedef Diff difference_type; |
53 | | typedef T* pointer; |
54 | | typedef T& reference; |
55 | | using element_type = T; |
56 | | using iterator_category = std::contiguous_iterator_tag; |
57 | | iterator() = default; |
58 | 239M | iterator(T* ptr_) : ptr(ptr_) {} _ZN9prevectorILj16EhjiE8iteratorC2EPh Line | Count | Source | 58 | 34.5M | iterator(T* ptr_) : ptr(ptr_) {} |
_ZN9prevectorILj28EhjiE8iteratorC2EPh Line | Count | Source | 58 | 204M | iterator(T* ptr_) : ptr(ptr_) {} |
_ZN9prevectorILj8EijiE8iteratorC2EPi Line | Count | Source | 58 | 184k | iterator(T* ptr_) : ptr(ptr_) {} |
_ZN9prevectorILj33EhjiE8iteratorC2EPh Line | Count | Source | 58 | 42 | iterator(T* ptr_) : ptr(ptr_) {} |
_ZN9prevectorILj35EhjiE8iteratorC2EPh Line | Count | Source | 58 | 484k | iterator(T* ptr_) : ptr(ptr_) {} |
|
59 | 592M | T& operator*() const { return *ptr; } _ZNK9prevectorILj28EhjiE8iteratordeEv Line | Count | Source | 59 | 522M | T& operator*() const { return *ptr; } |
_ZNK9prevectorILj16EhjiE8iteratordeEv Line | Count | Source | 59 | 69.1M | T& operator*() const { return *ptr; } |
_ZNK9prevectorILj8EijiE8iteratordeEv Line | Count | Source | 59 | 217k | T& operator*() const { return *ptr; } |
_ZNK9prevectorILj33EhjiE8iteratordeEv Line | Count | Source | 59 | 84 | T& operator*() const { return *ptr; } |
_ZNK9prevectorILj35EhjiE8iteratordeEv Line | Count | Source | 59 | 484k | T& operator*() const { return *ptr; } |
|
60 | 0 | T* operator->() const { return ptr; } Unexecuted instantiation: _ZNK9prevectorILj33EhjiE8iteratorptEv Unexecuted instantiation: _ZNK9prevectorILj28EhjiE8iteratorptEv Unexecuted instantiation: _ZNK9prevectorILj16EhjiE8iteratorptEv Unexecuted instantiation: _ZNK9prevectorILj35EhjiE8iteratorptEv |
61 | | T& operator[](size_type pos) const { return ptr[pos]; } |
62 | 353M | iterator& operator++() { ptr++; return *this; } |
63 | | iterator& operator--() { ptr--; return *this; } |
64 | | iterator operator++(int) { iterator copy(*this); ++(*this); return copy; } |
65 | | iterator operator--(int) { iterator copy(*this); --(*this); return copy; } |
66 | 95.2M | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } _ZmiN9prevectorILj28EhjiE8iteratorES1_ Line | Count | Source | 66 | 83.4M | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } |
_ZmiN9prevectorILj16EhjiE8iteratorES1_ Line | Count | Source | 66 | 11.5M | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } |
_ZmiN9prevectorILj8EijiE8iteratorES1_ Line | Count | Source | 66 | 52.2k | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } |
_ZmiN9prevectorILj33EhjiE8iteratorES1_ Line | Count | Source | 66 | 14 | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } |
_ZmiN9prevectorILj35EhjiE8iteratorES1_ Line | Count | Source | 66 | 242k | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } |
|
67 | 39.3k | iterator operator+(size_type n) const { return iterator(ptr + n); } _ZNK9prevectorILj28EhjiE8iteratorplEj Line | Count | Source | 67 | 256 | iterator operator+(size_type n) const { return iterator(ptr + n); } |
_ZNK9prevectorILj8EijiE8iteratorplEj Line | Count | Source | 67 | 39.1k | iterator operator+(size_type n) const { return iterator(ptr + n); } |
_ZNK9prevectorILj33EhjiE8iteratorplEj Line | Count | Source | 67 | 14 | iterator operator+(size_type n) const { return iterator(ptr + n); } |
|
68 | | iterator friend operator+(size_type n, iterator x) { return x + n; } |
69 | | iterator& operator+=(size_type n) { ptr += n; return *this; } |
70 | 3.48k | iterator operator-(size_type n) const { return iterator(ptr - n); } |
71 | | iterator& operator-=(size_type n) { ptr -= n; return *this; } |
72 | | bool operator==(iterator x) const { return ptr == x.ptr; } |
73 | 354M | bool operator!=(iterator x) const { return ptr != x.ptr; } |
74 | | bool operator>=(iterator x) const { return ptr >= x.ptr; } |
75 | | 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 | | }; |
79 | | |
80 | | class reverse_iterator { |
81 | | T* ptr{}; |
82 | | public: |
83 | | typedef Diff difference_type; |
84 | | typedef T value_type; |
85 | | typedef T* pointer; |
86 | | typedef T& reference; |
87 | | typedef std::bidirectional_iterator_tag iterator_category; |
88 | | reverse_iterator() = default; |
89 | | reverse_iterator(T* ptr_) : ptr(ptr_) {} |
90 | | T& operator*() const { return *ptr; } |
91 | | T* operator->() const { return ptr; } |
92 | | reverse_iterator& operator--() { ptr++; return *this; } |
93 | | reverse_iterator& operator++() { ptr--; return *this; } |
94 | | reverse_iterator operator++(int) { reverse_iterator copy(*this); ++(*this); return copy; } |
95 | | reverse_iterator operator--(int) { reverse_iterator copy(*this); --(*this); return copy; } |
96 | | bool operator==(reverse_iterator x) const { return ptr == x.ptr; } |
97 | | bool operator!=(reverse_iterator x) const { return ptr != x.ptr; } |
98 | | }; |
99 | | |
100 | | class const_iterator { |
101 | | const T* ptr{}; |
102 | | public: |
103 | | typedef Diff difference_type; |
104 | | typedef const T* pointer; |
105 | | typedef const T& reference; |
106 | | using element_type = const T; |
107 | | using iterator_category = std::contiguous_iterator_tag; |
108 | | const_iterator() = default; |
109 | 4.10G | const_iterator(const T* ptr_) : ptr(ptr_) {} _ZN9prevectorILj16EhjiE14const_iteratorC2EPKh Line | Count | Source | 109 | 1.44G | const_iterator(const T* ptr_) : ptr(ptr_) {} |
_ZN9prevectorILj28EhjiE14const_iteratorC2EPKh Line | Count | Source | 109 | 2.65G | const_iterator(const T* ptr_) : ptr(ptr_) {} |
_ZN9prevectorILj8EijiE14const_iteratorC2EPKi Line | Count | Source | 109 | 3.23M | const_iterator(const T* ptr_) : ptr(ptr_) {} |
|
110 | 773k | const_iterator(iterator x) : ptr(&(*x)) {} |
111 | 41.3G | const T& operator*() const { return *ptr; } _ZNK9prevectorILj28EhjiE14const_iteratordeEv Line | Count | Source | 111 | 33.9G | const T& operator*() const { return *ptr; } |
_ZNK9prevectorILj16EhjiE14const_iteratordeEv Line | Count | Source | 111 | 7.34G | const T& operator*() const { return *ptr; } |
_ZNK9prevectorILj8EijiE14const_iteratordeEv Line | Count | Source | 111 | 26.7M | const T& operator*() const { return *ptr; } |
|
112 | 0 | const T* operator->() const { return ptr; } Unexecuted instantiation: _ZNK9prevectorILj28EhjiE14const_iteratorptEv Unexecuted instantiation: _ZNK9prevectorILj16EhjiE14const_iteratorptEv |
113 | 933k | const T& operator[](size_type pos) const { return ptr[pos]; } _ZNK9prevectorILj8EijiE14const_iteratorixEj Line | Count | Source | 113 | 535k | const T& operator[](size_type pos) const { return ptr[pos]; } |
_ZNK9prevectorILj28EhjiE14const_iteratorixEj Line | Count | Source | 113 | 397k | const T& operator[](size_type pos) const { return ptr[pos]; } |
|
114 | 36.5G | const_iterator& operator++() { ptr++; return *this; } _ZN9prevectorILj28EhjiE14const_iteratorppEv Line | Count | Source | 114 | 30.2G | const_iterator& operator++() { ptr++; return *this; } |
_ZN9prevectorILj16EhjiE14const_iteratorppEv Line | Count | Source | 114 | 6.29G | const_iterator& operator++() { ptr++; return *this; } |
_ZN9prevectorILj8EijiE14const_iteratorppEv Line | Count | Source | 114 | 24.6M | const_iterator& operator++() { ptr++; return *this; } |
|
115 | 2.14M | const_iterator& operator--() { ptr--; return *this; } _ZN9prevectorILj8EijiE14const_iteratormmEv Line | Count | Source | 115 | 2.14M | const_iterator& operator--() { ptr--; return *this; } |
Unexecuted instantiation: _ZN9prevectorILj28EhjiE14const_iteratormmEv |
116 | 270M | const_iterator operator++(int) { const_iterator copy(*this); ++(*this); return copy; } |
117 | | const_iterator operator--(int) { const_iterator copy(*this); --(*this); return copy; } |
118 | 863M | difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); } _ZmiN9prevectorILj16EhjiE14const_iteratorES1_ Line | Count | Source | 118 | 63.2M | difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); } |
_ZmiN9prevectorILj28EhjiE14const_iteratorES1_ Line | Count | Source | 118 | 800M | difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); } |
_ZmiN9prevectorILj8EijiE14const_iteratorES1_ Line | Count | Source | 118 | 7.94k | difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); } |
|
119 | 78.1M | const_iterator operator+(size_type n) const { return const_iterator(ptr + n); } _ZNK9prevectorILj8EijiE14const_iteratorplEj Line | Count | Source | 119 | 1.07M | const_iterator operator+(size_type n) const { return const_iterator(ptr + n); } |
_ZNK9prevectorILj28EhjiE14const_iteratorplEj Line | Count | Source | 119 | 77.0M | const_iterator operator+(size_type n) const { return const_iterator(ptr + n); } |
|
120 | | const_iterator friend operator+(size_type n, const_iterator x) { return x + n; } |
121 | 82.6M | const_iterator& operator+=(size_type n) { ptr += n; return *this; } |
122 | 805k | const_iterator operator-(size_type n) const { return const_iterator(ptr - n); } _ZNK9prevectorILj8EijiE14const_iteratormiEj Line | Count | Source | 122 | 535k | const_iterator operator-(size_type n) const { return const_iterator(ptr - n); } |
_ZNK9prevectorILj28EhjiE14const_iteratormiEj Line | Count | Source | 122 | 269k | const_iterator operator-(size_type n) const { return const_iterator(ptr - n); } |
|
123 | | const_iterator& operator-=(size_type n) { ptr -= n; return *this; } |
124 | 1.15M | bool operator==(const_iterator x) const { return ptr == x.ptr; } _ZNK9prevectorILj8EijiE14const_iteratoreqES1_ Line | Count | Source | 124 | 1.07M | bool operator==(const_iterator x) const { return ptr == x.ptr; } |
_ZNK9prevectorILj16EhjiE14const_iteratoreqES1_ Line | Count | Source | 124 | 195 | bool operator==(const_iterator x) const { return ptr == x.ptr; } |
_ZNK9prevectorILj28EhjiE14const_iteratoreqES1_ Line | Count | Source | 124 | 80.2k | bool operator==(const_iterator x) const { return ptr == x.ptr; } |
|
125 | 35.9G | bool operator!=(const_iterator x) const { return ptr != x.ptr; } _ZNK9prevectorILj28EhjiE14const_iteratorneES1_ Line | Count | Source | 125 | 29.9G | bool operator!=(const_iterator x) const { return ptr != x.ptr; } |
_ZNK9prevectorILj16EhjiE14const_iteratorneES1_ Line | Count | Source | 125 | 6.00G | bool operator!=(const_iterator x) const { return ptr != x.ptr; } |
_ZNK9prevectorILj8EijiE14const_iteratorneES1_ Line | Count | Source | 125 | 23.5M | bool operator!=(const_iterator x) const { return ptr != x.ptr; } |
|
126 | 256M | bool operator>=(const_iterator x) const { return ptr >= x.ptr; } |
127 | | bool operator<=(const_iterator x) const { return ptr <= x.ptr; } |
128 | | bool operator>(const_iterator x) const { return ptr > x.ptr; } |
129 | 137M | bool operator<(const_iterator x) const { return ptr < x.ptr; } |
130 | | }; |
131 | | |
132 | | class const_reverse_iterator { |
133 | | const T* ptr{}; |
134 | | public: |
135 | | typedef Diff difference_type; |
136 | | typedef const T value_type; |
137 | | typedef const T* pointer; |
138 | | typedef const T& reference; |
139 | | typedef std::bidirectional_iterator_tag iterator_category; |
140 | | const_reverse_iterator() = default; |
141 | | const_reverse_iterator(const T* ptr_) : ptr(ptr_) {} |
142 | | const_reverse_iterator(reverse_iterator x) : ptr(&(*x)) {} |
143 | | const T& operator*() const { return *ptr; } |
144 | | const T* operator->() const { return ptr; } |
145 | | const_reverse_iterator& operator--() { ptr++; return *this; } |
146 | | const_reverse_iterator& operator++() { ptr--; return *this; } |
147 | | const_reverse_iterator operator++(int) { const_reverse_iterator copy(*this); ++(*this); return copy; } |
148 | | const_reverse_iterator operator--(int) { const_reverse_iterator copy(*this); --(*this); return copy; } |
149 | | bool operator==(const_reverse_iterator x) const { return ptr == x.ptr; } |
150 | | bool operator!=(const_reverse_iterator x) const { return ptr != x.ptr; } |
151 | | }; |
152 | | |
153 | | private: |
154 | | #pragma pack(push, 1) |
155 | | union direct_or_indirect { |
156 | | char direct[sizeof(T) * N]; |
157 | | struct { |
158 | | char* indirect; |
159 | | size_type capacity; |
160 | | } indirect_contents; |
161 | | }; |
162 | | #pragma pack(pop) |
163 | | alignas(char*) direct_or_indirect _union = {}; |
164 | | size_type _size = 0; |
165 | | |
166 | | static_assert(alignof(char*) % alignof(size_type) == 0 && sizeof(char*) % alignof(size_type) == 0, "size_type cannot have more restrictive alignment requirement than pointer"); |
167 | | static_assert(alignof(char*) % alignof(T) == 0, "value_type T cannot have more restrictive alignment requirement than pointer"); |
168 | | |
169 | 1.17G | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } _ZN9prevectorILj28EhjiE10direct_ptrEi Line | Count | Source | 169 | 878M | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } |
_ZN9prevectorILj33EhjiE10direct_ptrEi Line | Count | Source | 169 | 1.23M | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } |
_ZN9prevectorILj16EhjiE10direct_ptrEi Line | Count | Source | 169 | 294M | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } |
_ZN9prevectorILj8EijiE10direct_ptrEi Line | Count | Source | 169 | 67.7k | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } |
_ZN9prevectorILj35EhjiE10direct_ptrEi Line | Count | Source | 169 | 968k | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } |
|
170 | 2.94G | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } _ZNK9prevectorILj28EhjiE10direct_ptrEi Line | Count | Source | 170 | 786M | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } |
_ZNK9prevectorILj16EhjiE10direct_ptrEi Line | Count | Source | 170 | 2.15G | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } |
_ZNK9prevectorILj8EijiE10direct_ptrEi Line | Count | Source | 170 | 12.5k | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } |
_ZNK9prevectorILj33EhjiE10direct_ptrEi Line | Count | Source | 170 | 264k | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } |
|
171 | 975M | T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect_contents.indirect) + pos; } _ZN9prevectorILj28EhjiE12indirect_ptrEi Line | Count | Source | 171 | 891M | T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect_contents.indirect) + pos; } |
_ZN9prevectorILj33EhjiE12indirect_ptrEi Line | Count | Source | 171 | 517 | T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect_contents.indirect) + pos; } |
_ZN9prevectorILj16EhjiE12indirect_ptrEi Line | Count | Source | 171 | 83.7M | T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect_contents.indirect) + pos; } |
_ZN9prevectorILj8EijiE12indirect_ptrEi Line | Count | Source | 171 | 139k | T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect_contents.indirect) + pos; } |
Unexecuted instantiation: _ZN9prevectorILj35EhjiE12indirect_ptrEi |
172 | 2.86G | const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect_contents.indirect) + pos; } _ZNK9prevectorILj28EhjiE12indirect_ptrEi Line | Count | Source | 172 | 2.57G | const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect_contents.indirect) + pos; } |
_ZNK9prevectorILj16EhjiE12indirect_ptrEi Line | Count | Source | 172 | 294M | const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect_contents.indirect) + pos; } |
_ZNK9prevectorILj8EijiE12indirect_ptrEi Line | Count | Source | 172 | 3.75M | const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect_contents.indirect) + pos; } |
_ZNK9prevectorILj33EhjiE12indirect_ptrEi Line | Count | Source | 172 | 165 | const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect_contents.indirect) + pos; } |
|
173 | 19.9G | bool is_direct() const { return _size <= N; } _ZNK9prevectorILj28EhjiE9is_directEv Line | Count | Source | 173 | 14.8G | bool is_direct() const { return _size <= N; } |
_ZNK9prevectorILj33EhjiE9is_directEv Line | Count | Source | 173 | 4.52M | bool is_direct() const { return _size <= N; } |
_ZNK9prevectorILj16EhjiE9is_directEv Line | Count | Source | 173 | 5.01G | bool is_direct() const { return _size <= N; } |
_ZNK9prevectorILj8EijiE9is_directEv Line | Count | Source | 173 | 4.76M | bool is_direct() const { return _size <= N; } |
_ZNK9prevectorILj35EhjiE9is_directEv Line | Count | Source | 173 | 2.30M | bool is_direct() const { return _size <= N; } |
|
174 | | |
175 | 1.05G | void change_capacity(size_type new_capacity) { |
176 | 1.05G | if (new_capacity <= N) { |
177 | 278M | if (!is_direct()) { |
178 | 84.6k | T* indirect = indirect_ptr(0); |
179 | 84.6k | T* src = indirect; |
180 | 84.6k | T* dst = direct_ptr(0); |
181 | 84.6k | memcpy(dst, src, size() * sizeof(T)); |
182 | 84.6k | free(indirect); |
183 | 84.6k | _size -= N + 1; |
184 | 84.6k | } |
185 | 774M | } else { |
186 | 774M | if (!is_direct()) { |
187 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert |
188 | | success. These should instead use an allocator or new/delete so that handlers |
189 | | are called as necessary, but performance would be slightly degraded by doing so. */ |
190 | 611k | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); |
191 | 611k | assert(_union.indirect_contents.indirect); |
192 | 611k | _union.indirect_contents.capacity = new_capacity; |
193 | 774M | } else { |
194 | 774M | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); |
195 | 774M | assert(new_indirect); |
196 | 774M | T* src = direct_ptr(0); |
197 | 774M | T* dst = reinterpret_cast<T*>(new_indirect); |
198 | 774M | memcpy(dst, src, size() * sizeof(T)); |
199 | 774M | _union.indirect_contents.indirect = new_indirect; |
200 | 774M | _union.indirect_contents.capacity = new_capacity; |
201 | 774M | _size += N + 1; |
202 | 774M | } |
203 | 774M | } |
204 | 1.05G | } _ZN9prevectorILj28EhjiE15change_capacityEj Line | Count | Source | 175 | 813M | void change_capacity(size_type new_capacity) { | 176 | 813M | if (new_capacity <= N) { | 177 | 114M | if (!is_direct()) { | 178 | 83.9k | T* indirect = indirect_ptr(0); | 179 | 83.9k | T* src = indirect; | 180 | 83.9k | T* dst = direct_ptr(0); | 181 | 83.9k | memcpy(dst, src, size() * sizeof(T)); | 182 | 83.9k | free(indirect); | 183 | 83.9k | _size -= N + 1; | 184 | 83.9k | } | 185 | 698M | } else { | 186 | 698M | if (!is_direct()) { | 187 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert | 188 | | success. These should instead use an allocator or new/delete so that handlers | 189 | | are called as necessary, but performance would be slightly degraded by doing so. */ | 190 | 605k | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); | 191 | 605k | assert(_union.indirect_contents.indirect); | 192 | 605k | _union.indirect_contents.capacity = new_capacity; | 193 | 698M | } else { | 194 | 698M | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); | 195 | 698M | assert(new_indirect); | 196 | 698M | T* src = direct_ptr(0); | 197 | 698M | T* dst = reinterpret_cast<T*>(new_indirect); | 198 | 698M | memcpy(dst, src, size() * sizeof(T)); | 199 | 698M | _union.indirect_contents.indirect = new_indirect; | 200 | 698M | _union.indirect_contents.capacity = new_capacity; | 201 | 698M | _size += N + 1; | 202 | 698M | } | 203 | 698M | } | 204 | 813M | } |
_ZN9prevectorILj16EhjiE15change_capacityEj Line | Count | Source | 175 | 240M | void change_capacity(size_type new_capacity) { | 176 | 240M | if (new_capacity <= N) { | 177 | 164M | if (!is_direct()) { | 178 | 0 | T* indirect = indirect_ptr(0); | 179 | 0 | T* src = indirect; | 180 | 0 | T* dst = direct_ptr(0); | 181 | 0 | memcpy(dst, src, size() * sizeof(T)); | 182 | 0 | free(indirect); | 183 | 0 | _size -= N + 1; | 184 | 0 | } | 185 | 164M | } else { | 186 | 75.8M | if (!is_direct()) { | 187 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert | 188 | | success. These should instead use an allocator or new/delete so that handlers | 189 | | are called as necessary, but performance would be slightly degraded by doing so. */ | 190 | 0 | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); | 191 | 0 | assert(_union.indirect_contents.indirect); | 192 | 0 | _union.indirect_contents.capacity = new_capacity; | 193 | 75.8M | } else { | 194 | 75.8M | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); | 195 | 75.8M | assert(new_indirect); | 196 | 75.8M | T* src = direct_ptr(0); | 197 | 75.8M | T* dst = reinterpret_cast<T*>(new_indirect); | 198 | 75.8M | memcpy(dst, src, size() * sizeof(T)); | 199 | 75.8M | _union.indirect_contents.indirect = new_indirect; | 200 | 75.8M | _union.indirect_contents.capacity = new_capacity; | 201 | 75.8M | _size += N + 1; | 202 | 75.8M | } | 203 | 75.8M | } | 204 | 240M | } |
_ZN9prevectorILj33EhjiE15change_capacityEj Line | Count | Source | 175 | 264k | void change_capacity(size_type new_capacity) { | 176 | 264k | if (new_capacity <= N) { | 177 | 264k | if (!is_direct()) { | 178 | 0 | T* indirect = indirect_ptr(0); | 179 | 0 | T* src = indirect; | 180 | 0 | T* dst = direct_ptr(0); | 181 | 0 | memcpy(dst, src, size() * sizeof(T)); | 182 | 0 | free(indirect); | 183 | 0 | _size -= N + 1; | 184 | 0 | } | 185 | 264k | } else { | 186 | 517 | if (!is_direct()) { | 187 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert | 188 | | success. These should instead use an allocator or new/delete so that handlers | 189 | | are called as necessary, but performance would be slightly degraded by doing so. */ | 190 | 0 | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); | 191 | 0 | assert(_union.indirect_contents.indirect); | 192 | 0 | _union.indirect_contents.capacity = new_capacity; | 193 | 517 | } else { | 194 | 517 | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); | 195 | 517 | assert(new_indirect); | 196 | 517 | T* src = direct_ptr(0); | 197 | 517 | T* dst = reinterpret_cast<T*>(new_indirect); | 198 | 517 | memcpy(dst, src, size() * sizeof(T)); | 199 | 517 | _union.indirect_contents.indirect = new_indirect; | 200 | 517 | _union.indirect_contents.capacity = new_capacity; | 201 | 517 | _size += N + 1; | 202 | 517 | } | 203 | 517 | } | 204 | 264k | } |
_ZN9prevectorILj8EijiE15change_capacityEj Line | Count | Source | 175 | 13.3k | void change_capacity(size_type new_capacity) { | 176 | 13.3k | if (new_capacity <= N) { | 177 | 3.35k | if (!is_direct()) { | 178 | 766 | T* indirect = indirect_ptr(0); | 179 | 766 | T* src = indirect; | 180 | 766 | T* dst = direct_ptr(0); | 181 | 766 | memcpy(dst, src, size() * sizeof(T)); | 182 | 766 | free(indirect); | 183 | 766 | _size -= N + 1; | 184 | 766 | } | 185 | 10.0k | } else { | 186 | 10.0k | if (!is_direct()) { | 187 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert | 188 | | success. These should instead use an allocator or new/delete so that handlers | 189 | | are called as necessary, but performance would be slightly degraded by doing so. */ | 190 | 5.86k | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); | 191 | 5.86k | assert(_union.indirect_contents.indirect); | 192 | 5.86k | _union.indirect_contents.capacity = new_capacity; | 193 | 5.86k | } else { | 194 | 4.17k | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); | 195 | 4.17k | assert(new_indirect); | 196 | 4.17k | T* src = direct_ptr(0); | 197 | 4.17k | T* dst = reinterpret_cast<T*>(new_indirect); | 198 | 4.17k | memcpy(dst, src, size() * sizeof(T)); | 199 | 4.17k | _union.indirect_contents.indirect = new_indirect; | 200 | 4.17k | _union.indirect_contents.capacity = new_capacity; | 201 | 4.17k | _size += N + 1; | 202 | 4.17k | } | 203 | 10.0k | } | 204 | 13.3k | } |
_ZN9prevectorILj35EhjiE15change_capacityEj Line | Count | Source | 175 | 121k | void change_capacity(size_type new_capacity) { | 176 | 121k | if (new_capacity <= N) { | 177 | 121k | if (!is_direct()) { | 178 | 0 | T* indirect = indirect_ptr(0); | 179 | 0 | T* src = indirect; | 180 | 0 | T* dst = direct_ptr(0); | 181 | 0 | memcpy(dst, src, size() * sizeof(T)); | 182 | 0 | free(indirect); | 183 | 0 | _size -= N + 1; | 184 | 0 | } | 185 | 121k | } else { | 186 | 0 | if (!is_direct()) { | 187 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert | 188 | | success. These should instead use an allocator or new/delete so that handlers | 189 | | are called as necessary, but performance would be slightly degraded by doing so. */ | 190 | 0 | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); | 191 | 0 | assert(_union.indirect_contents.indirect); | 192 | 0 | _union.indirect_contents.capacity = new_capacity; | 193 | 0 | } else { | 194 | 0 | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); | 195 | 0 | assert(new_indirect); | 196 | 0 | T* src = direct_ptr(0); | 197 | 0 | T* dst = reinterpret_cast<T*>(new_indirect); | 198 | 0 | memcpy(dst, src, size() * sizeof(T)); | 199 | 0 | _union.indirect_contents.indirect = new_indirect; | 200 | 0 | _union.indirect_contents.capacity = new_capacity; | 201 | 0 | _size += N + 1; | 202 | 0 | } | 203 | 0 | } | 204 | 121k | } |
|
205 | | |
206 | 1.37G | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } _ZN9prevectorILj28EhjiE8item_ptrEi Line | Count | Source | 206 | 1.07G | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } |
_ZN9prevectorILj33EhjiE8item_ptrEi Line | Count | Source | 206 | 1.23M | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } |
_ZN9prevectorILj16EhjiE8item_ptrEi Line | Count | Source | 206 | 302M | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } |
_ZN9prevectorILj8EijiE8item_ptrEi Line | Count | Source | 206 | 201k | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } |
_ZN9prevectorILj35EhjiE8item_ptrEi Line | Count | Source | 206 | 968k | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } |
|
207 | 5.81G | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } _ZNK9prevectorILj28EhjiE8item_ptrEi Line | Count | Source | 207 | 3.35G | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } |
_ZNK9prevectorILj16EhjiE8item_ptrEi Line | Count | Source | 207 | 2.44G | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } |
_ZNK9prevectorILj8EijiE8item_ptrEi Line | Count | Source | 207 | 3.77M | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } |
_ZNK9prevectorILj33EhjiE8item_ptrEi Line | Count | Source | 207 | 264k | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } |
|
208 | | |
209 | 67.5M | void fill(T* dst, ptrdiff_t count, const T& value = T{}) { |
210 | 67.5M | std::fill_n(dst, count, value); |
211 | 67.5M | } _ZN9prevectorILj28EhjiE4fillEPhlRKh Line | Count | Source | 209 | 4.50M | void fill(T* dst, ptrdiff_t count, const T& value = T{}) { | 210 | 4.50M | std::fill_n(dst, count, value); | 211 | 4.50M | } |
_ZN9prevectorILj16EhjiE4fillEPhlRKh Line | Count | Source | 209 | 62.5M | void fill(T* dst, ptrdiff_t count, const T& value = T{}) { | 210 | 62.5M | std::fill_n(dst, count, value); | 211 | 62.5M | } |
_ZN9prevectorILj33EhjiE4fillEPhlRKh Line | Count | Source | 209 | 439k | void fill(T* dst, ptrdiff_t count, const T& value = T{}) { | 210 | 439k | std::fill_n(dst, count, value); | 211 | 439k | } |
_ZN9prevectorILj8EijiE4fillEPilRKi Line | Count | Source | 209 | 18.9k | void fill(T* dst, ptrdiff_t count, const T& value = T{}) { | 210 | 18.9k | std::fill_n(dst, count, value); | 211 | 18.9k | } |
|
212 | | |
213 | | template <std::input_iterator InputIterator> |
214 | 1.03G | void fill(T* dst, InputIterator first, InputIterator last) { |
215 | 32.9G | while (first != last) { |
216 | 31.9G | new(static_cast<void*>(dst)) T(*first); |
217 | 31.9G | ++dst; |
218 | 31.9G | ++first; |
219 | 31.9G | } |
220 | 1.03G | } _ZN9prevectorILj28EhjiE4fillITkSt14input_iteratorPKhEEvPhT_S5_ Line | Count | Source | 214 | 6.46k | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 19.6k | while (first != last) { | 216 | 13.1k | new(static_cast<void*>(dst)) T(*first); | 217 | 13.1k | ++dst; | 218 | 13.1k | ++first; | 219 | 13.1k | } | 220 | 6.46k | } |
_ZN9prevectorILj28EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvPhT_SA_ Line | Count | Source | 214 | 16.4M | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 1.35G | while (first != last) { | 216 | 1.34G | new(static_cast<void*>(dst)) T(*first); | 217 | 1.34G | ++dst; | 218 | 1.34G | ++first; | 219 | 1.34G | } | 220 | 16.4M | } |
_ZN9prevectorILj28EhjiE4fillITkSt14input_iteratorNS0_14const_iteratorEEEvPhT_S4_ Line | Count | Source | 214 | 823M | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 27.0G | while (first != last) { | 216 | 26.2G | new(static_cast<void*>(dst)) T(*first); | 217 | 26.2G | ++dst; | 218 | 26.2G | ++first; | 219 | 26.2G | } | 220 | 823M | } |
_ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorNS0_14const_iteratorEEEvPhT_S4_ Line | Count | Source | 214 | 181M | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 3.82G | while (first != last) { | 216 | 3.64G | new(static_cast<void*>(dst)) T(*first); | 217 | 3.64G | ++dst; | 218 | 3.64G | ++first; | 219 | 3.64G | } | 220 | 181M | } |
_ZN9prevectorILj28EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt6vectorIhSaIhEEEEEEvPhT_SB_ Line | Count | Source | 214 | 2.47M | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 23.4M | while (first != last) { | 216 | 20.9M | new(static_cast<void*>(dst)) T(*first); | 217 | 20.9M | ++dst; | 218 | 20.9M | ++first; | 219 | 20.9M | } | 220 | 2.47M | } |
_ZN9prevectorILj28EhjiE4fillITkSt14input_iteratorNS0_8iteratorEEEvPhT_S4_ Line | Count | Source | 214 | 749k | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 344M | while (first != last) { | 216 | 344M | new(static_cast<void*>(dst)) T(*first); | 217 | 344M | ++dst; | 218 | 344M | ++first; | 219 | 344M | } | 220 | 749k | } |
_ZN9prevectorILj8EijiE4fillITkSt14input_iteratorPiEEvS2_T_S3_ Line | Count | Source | 214 | 5.19k | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 16.0k | while (first != last) { | 216 | 10.8k | new(static_cast<void*>(dst)) T(*first); | 217 | 10.8k | ++dst; | 218 | 10.8k | ++first; | 219 | 10.8k | } | 220 | 5.19k | } |
_ZN9prevectorILj8EijiE4fillITkSt14input_iteratorNS0_14const_iteratorEEEvPiT_S4_ Line | Count | Source | 214 | 7.94k | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 20.8M | while (first != last) { | 216 | 20.8M | new(static_cast<void*>(dst)) T(*first); | 217 | 20.8M | ++dst; | 218 | 20.8M | ++first; | 219 | 20.8M | } | 220 | 7.94k | } |
_ZN9prevectorILj8EijiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEEEEvPiT_SB_ Line | Count | Source | 214 | 161 | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 536k | while (first != last) { | 216 | 535k | new(static_cast<void*>(dst)) T(*first); | 217 | 535k | ++dst; | 218 | 535k | ++first; | 219 | 535k | } | 220 | 161 | } |
_ZN9prevectorILj33EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt6vectorIhSaIhEEEEEEvPhT_SB_ Line | Count | Source | 214 | 2.12k | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 251k | while (first != last) { | 216 | 249k | new(static_cast<void*>(dst)) T(*first); | 217 | 249k | ++dst; | 218 | 249k | ++first; | 219 | 249k | } | 220 | 2.12k | } |
_ZN9prevectorILj28EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEEvS4_T_S9_ Line | Count | Source | 214 | 2.85M | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 274M | while (first != last) { | 216 | 271M | new(static_cast<void*>(dst)) T(*first); | 217 | 271M | ++dst; | 218 | 271M | ++first; | 219 | 271M | } | 220 | 2.85M | } |
_ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvPhT_SA_ Line | Count | Source | 214 | 416k | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 7.14M | while (first != last) { | 216 | 6.73M | new(static_cast<void*>(dst)) T(*first); | 217 | 6.73M | ++dst; | 218 | 6.73M | ++first; | 219 | 6.73M | } | 220 | 416k | } |
_ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorPhEEvS2_T_S3_ Line | Count | Source | 214 | 1.45M | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 16.0M | while (first != last) { | 216 | 14.5M | new(static_cast<void*>(dst)) T(*first); | 217 | 14.5M | ++dst; | 218 | 14.5M | ++first; | 219 | 14.5M | } | 220 | 1.45M | } |
_ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEEvS4_T_S9_ Line | Count | Source | 214 | 14.6k | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 484k | while (first != last) { | 216 | 469k | new(static_cast<void*>(dst)) T(*first); | 217 | 469k | ++dst; | 218 | 469k | ++first; | 219 | 469k | } | 220 | 14.6k | } |
_ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorPKhEEvPhT_S5_ Line | Count | Source | 214 | 35.2k | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 176k | while (first != last) { | 216 | 141k | new(static_cast<void*>(dst)) T(*first); | 217 | 141k | ++dst; | 218 | 141k | ++first; | 219 | 141k | } | 220 | 35.2k | } |
_ZN9prevectorILj35EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvPhT_SA_ Line | Count | Source | 214 | 121k | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 3.99M | while (first != last) { | 216 | 3.87M | new(static_cast<void*>(dst)) T(*first); | 217 | 3.87M | ++dst; | 218 | 3.87M | ++first; | 219 | 3.87M | } | 220 | 121k | } |
_ZN9prevectorILj35EhjiE4fillITkSt14input_iteratorPhEEvS2_T_S3_ Line | Count | Source | 214 | 121k | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 363k | while (first != last) { | 216 | 242k | new(static_cast<void*>(dst)) T(*first); | 217 | 242k | ++dst; | 218 | 242k | ++first; | 219 | 242k | } | 220 | 121k | } |
_ZN9prevectorILj35EhjiE4fillITkSt14input_iteratorPKhEEvPhT_S5_ Line | Count | Source | 214 | 121k | void fill(T* dst, InputIterator first, InputIterator last) { | 215 | 242k | while (first != last) { | 216 | 121k | new(static_cast<void*>(dst)) T(*first); | 217 | 121k | ++dst; | 218 | 121k | ++first; | 219 | 121k | } | 220 | 121k | } |
|
221 | | |
222 | | public: |
223 | 718k | void assign(size_type n, const T& val) { |
224 | 718k | clear(); |
225 | 718k | if (capacity() < n) { |
226 | 1.97k | change_capacity(n); |
227 | 1.97k | } |
228 | 718k | _size += n; |
229 | 718k | fill(item_ptr(0), n, val); |
230 | 718k | } _ZN9prevectorILj16EhjiE6assignEjRKh Line | Count | Source | 223 | 710k | void assign(size_type n, const T& val) { | 224 | 710k | clear(); | 225 | 710k | if (capacity() < n) { | 226 | 0 | change_capacity(n); | 227 | 0 | } | 228 | 710k | _size += n; | 229 | 710k | fill(item_ptr(0), n, val); | 230 | 710k | } |
_ZN9prevectorILj8EijiE6assignEjRKi Line | Count | Source | 223 | 8.03k | void assign(size_type n, const T& val) { | 224 | 8.03k | clear(); | 225 | 8.03k | if (capacity() < n) { | 226 | 1.97k | change_capacity(n); | 227 | 1.97k | } | 228 | 8.03k | _size += n; | 229 | 8.03k | fill(item_ptr(0), n, val); | 230 | 8.03k | } |
|
231 | | |
232 | | template <std::input_iterator InputIterator> |
233 | 254M | void assign(InputIterator first, InputIterator last) { |
234 | 254M | size_type n = last - first; |
235 | 254M | clear(); |
236 | 254M | if (capacity() < n) { |
237 | 223M | change_capacity(n); |
238 | 223M | } |
239 | 254M | _size += n; |
240 | 254M | fill(item_ptr(0), first, last); |
241 | 254M | } _ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorNS0_14const_iteratorEEEvT_S3_ Line | Count | Source | 233 | 5.54M | void assign(InputIterator first, InputIterator last) { | 234 | 5.54M | size_type n = last - first; | 235 | 5.54M | clear(); | 236 | 5.54M | if (capacity() < n) { | 237 | 2.00M | change_capacity(n); | 238 | 2.00M | } | 239 | 5.54M | _size += n; | 240 | 5.54M | fill(item_ptr(0), first, last); | 241 | 5.54M | } |
_ZN9prevectorILj28EhjiE6assignITkSt14input_iteratorNS0_14const_iteratorEEEvT_S3_ Line | Count | Source | 233 | 246M | void assign(InputIterator first, InputIterator last) { | 234 | 246M | size_type n = last - first; | 235 | 246M | clear(); | 236 | 246M | if (capacity() < n) { | 237 | 221M | change_capacity(n); | 238 | 221M | } | 239 | 246M | _size += n; | 240 | 246M | fill(item_ptr(0), first, last); | 241 | 246M | } |
_ZN9prevectorILj8EijiE6assignITkSt14input_iteratorNS0_14const_iteratorEEEvT_S3_ Line | Count | Source | 233 | 7.78k | void assign(InputIterator first, InputIterator last) { | 234 | 7.78k | size_type n = last - first; | 235 | 7.78k | clear(); | 236 | 7.78k | if (capacity() < n) { | 237 | 747 | change_capacity(n); | 238 | 747 | } | 239 | 7.78k | _size += n; | 240 | 7.78k | fill(item_ptr(0), first, last); | 241 | 7.78k | } |
_ZN9prevectorILj33EhjiE6assignITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt6vectorIhSaIhEEEEEEvT_SA_ Line | Count | Source | 233 | 2.12k | void assign(InputIterator first, InputIterator last) { | 234 | 2.12k | size_type n = last - first; | 235 | 2.12k | clear(); | 236 | 2.12k | if (capacity() < n) { | 237 | 517 | change_capacity(n); | 238 | 517 | } | 239 | 2.12k | _size += n; | 240 | 2.12k | fill(item_ptr(0), first, last); | 241 | 2.12k | } |
_ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvT_S9_ Line | Count | Source | 233 | 416k | void assign(InputIterator first, InputIterator last) { | 234 | 416k | size_type n = last - first; | 235 | 416k | clear(); | 236 | 416k | if (capacity() < n) { | 237 | 5.91k | change_capacity(n); | 238 | 5.91k | } | 239 | 416k | _size += n; | 240 | 416k | fill(item_ptr(0), first, last); | 241 | 416k | } |
_ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorPhEEvT_S3_ Line | Count | Source | 233 | 1.45M | void assign(InputIterator first, InputIterator last) { | 234 | 1.45M | size_type n = last - first; | 235 | 1.45M | clear(); | 236 | 1.45M | if (capacity() < n) { | 237 | 0 | change_capacity(n); | 238 | 0 | } | 239 | 1.45M | _size += n; | 240 | 1.45M | fill(item_ptr(0), first, last); | 241 | 1.45M | } |
_ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEEvT_S9_ Line | Count | Source | 233 | 14.6k | void assign(InputIterator first, InputIterator last) { | 234 | 14.6k | size_type n = last - first; | 235 | 14.6k | clear(); | 236 | 14.6k | if (capacity() < n) { | 237 | 14.6k | change_capacity(n); | 238 | 14.6k | } | 239 | 14.6k | _size += n; | 240 | 14.6k | fill(item_ptr(0), first, last); | 241 | 14.6k | } |
_ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorPKhEEvT_S4_ Line | Count | Source | 233 | 35.2k | void assign(InputIterator first, InputIterator last) { | 234 | 35.2k | size_type n = last - first; | 235 | 35.2k | clear(); | 236 | 35.2k | if (capacity() < n) { | 237 | 0 | change_capacity(n); | 238 | 0 | } | 239 | 35.2k | _size += n; | 240 | 35.2k | fill(item_ptr(0), first, last); | 241 | 35.2k | } |
|
242 | | |
243 | 350M | prevector() = default; _ZN9prevectorILj28EhjiEC2Ev Line | Count | Source | 243 | 348M | prevector() = default; |
_ZN9prevectorILj33EhjiEC2Ev Line | Count | Source | 243 | 1.70M | prevector() = default; |
_ZN9prevectorILj8EijiEC2Ev Line | Count | Source | 243 | 322 | prevector() = default; |
|
244 | | |
245 | | explicit prevector(size_type n) { |
246 | | resize(n); |
247 | | } |
248 | | |
249 | 54.3M | explicit prevector(size_type n, const T& val) { |
250 | 54.3M | change_capacity(n); |
251 | 54.3M | _size += n; |
252 | 54.3M | fill(item_ptr(0), n, val); |
253 | 54.3M | } _ZN9prevectorILj33EhjiEC2EjRKh Line | Count | Source | 249 | 264k | explicit prevector(size_type n, const T& val) { | 250 | 264k | change_capacity(n); | 251 | 264k | _size += n; | 252 | 264k | fill(item_ptr(0), n, val); | 253 | 264k | } |
_ZN9prevectorILj16EhjiEC2EjRKh Line | Count | Source | 249 | 54.0M | explicit prevector(size_type n, const T& val) { | 250 | 54.0M | change_capacity(n); | 251 | 54.0M | _size += n; | 252 | 54.0M | fill(item_ptr(0), n, val); | 253 | 54.0M | } |
|
254 | | |
255 | | template <std::input_iterator InputIterator> |
256 | 2.94M | prevector(InputIterator first, InputIterator last) { |
257 | 2.94M | size_type n = last - first; |
258 | 2.94M | change_capacity(n); |
259 | 2.94M | _size += n; |
260 | 2.94M | fill(item_ptr(0), first, last); |
261 | 2.94M | } _ZN9prevectorILj28EhjiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt6vectorIhSaIhEEEEEET_SA_ Line | Count | Source | 256 | 2.47M | prevector(InputIterator first, InputIterator last) { | 257 | 2.47M | size_type n = last - first; | 258 | 2.47M | change_capacity(n); | 259 | 2.47M | _size += n; | 260 | 2.47M | fill(item_ptr(0), first, last); | 261 | 2.47M | } |
_ZN9prevectorILj8EijiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKiSt6vectorIiSaIiEEEEEET_SA_ Line | Count | Source | 256 | 161 | prevector(InputIterator first, InputIterator last) { | 257 | 161 | size_type n = last - first; | 258 | 161 | change_capacity(n); | 259 | 161 | _size += n; | 260 | 161 | fill(item_ptr(0), first, last); | 261 | 161 | } |
_ZN9prevectorILj8EijiEC2ITkSt14input_iteratorNS0_14const_iteratorEEET_S3_ Line | Count | Source | 256 | 161 | prevector(InputIterator first, InputIterator last) { | 257 | 161 | size_type n = last - first; | 258 | 161 | change_capacity(n); | 259 | 161 | _size += n; | 260 | 161 | fill(item_ptr(0), first, last); | 261 | 161 | } |
_ZN9prevectorILj28EhjiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEET_S9_ Line | Count | Source | 256 | 39.0k | prevector(InputIterator first, InputIterator last) { | 257 | 39.0k | size_type n = last - first; | 258 | 39.0k | change_capacity(n); | 259 | 39.0k | _size += n; | 260 | 39.0k | fill(item_ptr(0), first, last); | 261 | 39.0k | } |
_ZN9prevectorILj35EhjiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEET_S9_ Line | Count | Source | 256 | 121k | prevector(InputIterator first, InputIterator last) { | 257 | 121k | size_type n = last - first; | 258 | 121k | change_capacity(n); | 259 | 121k | _size += n; | 260 | 121k | fill(item_ptr(0), first, last); | 261 | 121k | } |
_ZN9prevectorILj28EhjiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEET_S9_ Line | Count | Source | 256 | 418 | prevector(InputIterator first, InputIterator last) { | 257 | 418 | size_type n = last - first; | 258 | 418 | change_capacity(n); | 259 | 418 | _size += n; | 260 | 418 | fill(item_ptr(0), first, last); | 261 | 418 | } |
_ZN9prevectorILj28EhjiEC2ITkSt14input_iteratorNS0_14const_iteratorEEET_S3_ Line | Count | Source | 256 | 300k | prevector(InputIterator first, InputIterator last) { | 257 | 300k | size_type n = last - first; | 258 | 300k | change_capacity(n); | 259 | 300k | _size += n; | 260 | 300k | fill(item_ptr(0), first, last); | 261 | 300k | } |
|
262 | | |
263 | 727M | prevector(const prevector<N, T, Size, Diff>& other) { |
264 | 727M | size_type n = other.size(); |
265 | 727M | change_capacity(n); |
266 | 727M | _size += n; |
267 | 727M | fill(item_ptr(0), other.begin(), other.end()); |
268 | 727M | } _ZN9prevectorILj16EhjiEC2ERKS0_ Line | Count | Source | 263 | 176M | prevector(const prevector<N, T, Size, Diff>& other) { | 264 | 176M | size_type n = other.size(); | 265 | 176M | change_capacity(n); | 266 | 176M | _size += n; | 267 | 176M | fill(item_ptr(0), other.begin(), other.end()); | 268 | 176M | } |
_ZN9prevectorILj28EhjiEC2ERKS0_ Line | Count | Source | 263 | 551M | prevector(const prevector<N, T, Size, Diff>& other) { | 264 | 551M | size_type n = other.size(); | 265 | 551M | change_capacity(n); | 266 | 551M | _size += n; | 267 | 551M | fill(item_ptr(0), other.begin(), other.end()); | 268 | 551M | } |
|
269 | | |
270 | | prevector(prevector<N, T, Size, Diff>&& other) noexcept |
271 | 382M | : _union(std::move(other._union)), _size(other._size) |
272 | 382M | { |
273 | 382M | other._size = 0; |
274 | 382M | } _ZN9prevectorILj16EhjiEC2EOS0_ Line | Count | Source | 271 | 7.55M | : _union(std::move(other._union)), _size(other._size) | 272 | 7.55M | { | 273 | 7.55M | other._size = 0; | 274 | 7.55M | } |
_ZN9prevectorILj28EhjiEC2EOS0_ Line | Count | Source | 271 | 375M | : _union(std::move(other._union)), _size(other._size) | 272 | 375M | { | 273 | 375M | other._size = 0; | 274 | 375M | } |
|
275 | | |
276 | 252M | prevector& operator=(const prevector<N, T, Size, Diff>& other) { |
277 | 252M | if (&other == this) { |
278 | 0 | return *this; |
279 | 0 | } |
280 | 252M | assign(other.begin(), other.end()); |
281 | 252M | return *this; |
282 | 252M | } _ZN9prevectorILj16EhjiEaSERKS0_ Line | Count | Source | 276 | 5.54M | prevector& operator=(const prevector<N, T, Size, Diff>& other) { | 277 | 5.54M | if (&other == this) { | 278 | 0 | return *this; | 279 | 0 | } | 280 | 5.54M | assign(other.begin(), other.end()); | 281 | 5.54M | return *this; | 282 | 5.54M | } |
_ZN9prevectorILj28EhjiEaSERKS0_ Line | Count | Source | 276 | 246M | prevector& operator=(const prevector<N, T, Size, Diff>& other) { | 277 | 246M | if (&other == this) { | 278 | 0 | return *this; | 279 | 0 | } | 280 | 246M | assign(other.begin(), other.end()); | 281 | 246M | return *this; | 282 | 246M | } |
_ZN9prevectorILj8EijiEaSERKS0_ Line | Count | Source | 276 | 7.78k | prevector& operator=(const prevector<N, T, Size, Diff>& other) { | 277 | 7.78k | if (&other == this) { | 278 | 0 | return *this; | 279 | 0 | } | 280 | 7.78k | assign(other.begin(), other.end()); | 281 | 7.78k | return *this; | 282 | 7.78k | } |
|
283 | | |
284 | 40.4M | prevector& operator=(prevector<N, T, Size, Diff>&& other) noexcept { |
285 | 40.4M | if (!is_direct()) { |
286 | 91.9k | free(_union.indirect_contents.indirect); |
287 | 91.9k | } |
288 | 40.4M | _union = std::move(other._union); |
289 | 40.4M | _size = other._size; |
290 | 40.4M | other._size = 0; |
291 | 40.4M | return *this; |
292 | 40.4M | } _ZN9prevectorILj16EhjiEaSEOS0_ Line | Count | Source | 284 | 25.4M | prevector& operator=(prevector<N, T, Size, Diff>&& other) noexcept { | 285 | 25.4M | if (!is_direct()) { | 286 | 5.98k | free(_union.indirect_contents.indirect); | 287 | 5.98k | } | 288 | 25.4M | _union = std::move(other._union); | 289 | 25.4M | _size = other._size; | 290 | 25.4M | other._size = 0; | 291 | 25.4M | return *this; | 292 | 25.4M | } |
_ZN9prevectorILj28EhjiEaSEOS0_ Line | Count | Source | 284 | 15.0M | prevector& operator=(prevector<N, T, Size, Diff>&& other) noexcept { | 285 | 15.0M | if (!is_direct()) { | 286 | 82.7k | free(_union.indirect_contents.indirect); | 287 | 82.7k | } | 288 | 15.0M | _union = std::move(other._union); | 289 | 15.0M | _size = other._size; | 290 | 15.0M | other._size = 0; | 291 | 15.0M | return *this; | 292 | 15.0M | } |
_ZN9prevectorILj8EijiEaSEOS0_ Line | Count | Source | 284 | 7.75k | prevector& operator=(prevector<N, T, Size, Diff>&& other) noexcept { | 285 | 7.75k | if (!is_direct()) { | 286 | 3.15k | free(_union.indirect_contents.indirect); | 287 | 3.15k | } | 288 | 7.75k | _union = std::move(other._union); | 289 | 7.75k | _size = other._size; | 290 | 7.75k | other._size = 0; | 291 | 7.75k | return *this; | 292 | 7.75k | } |
|
293 | | |
294 | 9.71G | size_type size() const { |
295 | 9.71G | return is_direct() ? _size : _size - N - 1; |
296 | 9.71G | } _ZNK9prevectorILj28EhjiE4sizeEv Line | Count | Source | 294 | 7.97G | size_type size() const { | 295 | 7.97G | return is_direct() ? _size : _size - N - 1; | 296 | 7.97G | } |
_ZNK9prevectorILj33EhjiE4sizeEv Line | Count | Source | 294 | 618k | size_type size() const { | 295 | 618k | return is_direct() ? _size : _size - N - 1; | 296 | 618k | } |
_ZNK9prevectorILj16EhjiE4sizeEv Line | Count | Source | 294 | 1.74G | size_type size() const { | 295 | 1.74G | return is_direct() ? _size : _size - N - 1; | 296 | 1.74G | } |
_ZNK9prevectorILj8EijiE4sizeEv Line | Count | Source | 294 | 713k | size_type size() const { | 295 | 713k | return is_direct() ? _size : _size - N - 1; | 296 | 713k | } |
_ZNK9prevectorILj35EhjiE4sizeEv Line | Count | Source | 294 | 847k | size_type size() const { | 295 | 847k | return is_direct() ? _size : _size - N - 1; | 296 | 847k | } |
|
297 | | |
298 | 1.66G | bool empty() const { |
299 | 1.66G | return size() == 0; |
300 | 1.66G | } _ZNK9prevectorILj28EhjiE5emptyEv Line | Count | Source | 298 | 1.65G | bool empty() const { | 299 | 1.65G | return size() == 0; | 300 | 1.65G | } |
_ZNK9prevectorILj16EhjiE5emptyEv Line | Count | Source | 298 | 11.8M | bool empty() const { | 299 | 11.8M | return size() == 0; | 300 | 11.8M | } |
_ZNK9prevectorILj8EijiE5emptyEv Line | Count | Source | 298 | 161 | bool empty() const { | 299 | 161 | return size() == 0; | 300 | 161 | } |
|
301 | | |
302 | 83.9M | iterator begin() { return iterator(item_ptr(0)); } _ZN9prevectorILj33EhjiE5beginEv Line | Count | Source | 302 | 14 | iterator begin() { return iterator(item_ptr(0)); } |
_ZN9prevectorILj28EhjiE5beginEv Line | Count | Source | 302 | 83.6M | iterator begin() { return iterator(item_ptr(0)); } |
Unexecuted instantiation: _ZN9prevectorILj16EhjiE5beginEv _ZN9prevectorILj8EijiE5beginEv Line | Count | Source | 302 | 60.5k | iterator begin() { return iterator(item_ptr(0)); } |
_ZN9prevectorILj35EhjiE5beginEv Line | Count | Source | 302 | 242k | iterator begin() { return iterator(item_ptr(0)); } |
|
303 | 2.37G | const_iterator begin() const { return const_iterator(item_ptr(0)); } _ZNK9prevectorILj28EhjiE5beginEv Line | Count | Source | 303 | 1.20G | const_iterator begin() const { return const_iterator(item_ptr(0)); } |
_ZNK9prevectorILj16EhjiE5beginEv Line | Count | Source | 303 | 1.17G | const_iterator begin() const { return const_iterator(item_ptr(0)); } |
_ZNK9prevectorILj8EijiE5beginEv Line | Count | Source | 303 | 1.08M | const_iterator begin() const { return const_iterator(item_ptr(0)); } |
|
304 | 107M | iterator end() { return iterator(item_ptr(size())); } _ZN9prevectorILj28EhjiE3endEv Line | Count | Source | 304 | 84.3M | iterator end() { return iterator(item_ptr(size())); } |
_ZN9prevectorILj33EhjiE3endEv Line | Count | Source | 304 | 14 | iterator end() { return iterator(item_ptr(size())); } |
_ZN9prevectorILj16EhjiE3endEv Line | Count | Source | 304 | 23.0M | iterator end() { return iterator(item_ptr(size())); } |
_ZN9prevectorILj8EijiE3endEv Line | Count | Source | 304 | 52.5k | iterator end() { return iterator(item_ptr(size())); } |
_ZN9prevectorILj35EhjiE3endEv Line | Count | Source | 304 | 242k | iterator end() { return iterator(item_ptr(size())); } |
|
305 | 1.64G | const_iterator end() const { return const_iterator(item_ptr(size())); } _ZNK9prevectorILj28EhjiE3endEv Line | Count | Source | 305 | 1.36G | const_iterator end() const { return const_iterator(item_ptr(size())); } |
_ZNK9prevectorILj16EhjiE3endEv Line | Count | Source | 305 | 276M | const_iterator end() const { return const_iterator(item_ptr(size())); } |
_ZNK9prevectorILj8EijiE3endEv Line | Count | Source | 305 | 545k | const_iterator end() const { return const_iterator(item_ptr(size())); } |
|
306 | | |
307 | | reverse_iterator rbegin() { return reverse_iterator(item_ptr(size() - 1)); } |
308 | | const_reverse_iterator rbegin() const { return const_reverse_iterator(item_ptr(size() - 1)); } |
309 | | reverse_iterator rend() { return reverse_iterator(item_ptr(-1)); } |
310 | | const_reverse_iterator rend() const { return const_reverse_iterator(item_ptr(-1)); } |
311 | | |
312 | 356M | size_t capacity() const { |
313 | 356M | if (is_direct()) { |
314 | 292M | return N; |
315 | 292M | } else { |
316 | 63.5M | return _union.indirect_contents.capacity; |
317 | 63.5M | } |
318 | 356M | } _ZNK9prevectorILj28EhjiE8capacityEv Line | Count | Source | 312 | 339M | size_t capacity() const { | 313 | 339M | if (is_direct()) { | 314 | 276M | return N; | 315 | 276M | } else { | 316 | 63.5M | return _union.indirect_contents.capacity; | 317 | 63.5M | } | 318 | 339M | } |
_ZNK9prevectorILj16EhjiE8capacityEv Line | Count | Source | 312 | 15.9M | size_t capacity() const { | 313 | 15.9M | if (is_direct()) { | 314 | 15.9M | return N; | 315 | 15.9M | } else { | 316 | 27.1k | return _union.indirect_contents.capacity; | 317 | 27.1k | } | 318 | 15.9M | } |
_ZNK9prevectorILj8EijiE8capacityEv Line | Count | Source | 312 | 57.4k | size_t capacity() const { | 313 | 57.4k | if (is_direct()) { | 314 | 23.4k | return N; | 315 | 34.0k | } else { | 316 | 34.0k | return _union.indirect_contents.capacity; | 317 | 34.0k | } | 318 | 57.4k | } |
_ZNK9prevectorILj33EhjiE8capacityEv Line | Count | Source | 312 | 176k | size_t capacity() const { | 313 | 176k | if (is_direct()) { | 314 | 176k | return N; | 315 | 176k | } else { | 316 | 0 | return _union.indirect_contents.capacity; | 317 | 0 | } | 318 | 176k | } |
_ZNK9prevectorILj35EhjiE8capacityEv Line | Count | Source | 312 | 242k | size_t capacity() const { | 313 | 242k | if (is_direct()) { | 314 | 242k | return N; | 315 | 242k | } else { | 316 | 0 | return _union.indirect_contents.capacity; | 317 | 0 | } | 318 | 242k | } |
|
319 | | |
320 | 9.37M | T& operator[](size_type pos) { |
321 | 9.37M | return *item_ptr(pos); |
322 | 9.37M | } _ZN9prevectorILj28EhjiEixEj Line | Count | Source | 320 | 8.42M | T& operator[](size_type pos) { | 321 | 8.42M | return *item_ptr(pos); | 322 | 8.42M | } |
_ZN9prevectorILj8EijiEixEj Line | Count | Source | 320 | 17.5k | T& operator[](size_type pos) { | 321 | 17.5k | return *item_ptr(pos); | 322 | 17.5k | } |
_ZN9prevectorILj33EhjiEixEj Line | Count | Source | 320 | 349k | T& operator[](size_type pos) { | 321 | 349k | return *item_ptr(pos); | 322 | 349k | } |
_ZN9prevectorILj16EhjiEixEj Line | Count | Source | 320 | 578k | T& operator[](size_type pos) { | 321 | 578k | return *item_ptr(pos); | 322 | 578k | } |
|
323 | | |
324 | 725M | const T& operator[](size_type pos) const { |
325 | 725M | return *item_ptr(pos); |
326 | 725M | } _ZNK9prevectorILj16EhjiEixEj Line | Count | Source | 324 | 559M | const T& operator[](size_type pos) const { | 325 | 559M | return *item_ptr(pos); | 326 | 559M | } |
_ZNK9prevectorILj28EhjiEixEj Line | Count | Source | 324 | 163M | const T& operator[](size_type pos) const { | 325 | 163M | return *item_ptr(pos); | 326 | 163M | } |
_ZNK9prevectorILj8EijiEixEj Line | Count | Source | 324 | 2.14M | const T& operator[](size_type pos) const { | 325 | 2.14M | return *item_ptr(pos); | 326 | 2.14M | } |
|
327 | | |
328 | 328M | void resize(size_type new_size) { |
329 | 328M | size_type cur_size = size(); |
330 | 328M | if (cur_size == new_size) { |
331 | 304M | return; |
332 | 304M | } |
333 | 24.3M | if (cur_size > new_size) { |
334 | 11.9M | erase(item_ptr(new_size), end()); |
335 | 11.9M | return; |
336 | 11.9M | } |
337 | 12.4M | if (new_size > capacity()) { |
338 | 8.04M | change_capacity(new_size); |
339 | 8.04M | } |
340 | 12.4M | ptrdiff_t increase = new_size - cur_size; |
341 | 12.4M | fill(item_ptr(cur_size), increase); |
342 | 12.4M | _size += increase; |
343 | 12.4M | } _ZN9prevectorILj28EhjiE6resizeEj Line | Count | Source | 328 | 299M | void resize(size_type new_size) { | 329 | 299M | size_type cur_size = size(); | 330 | 299M | if (cur_size == new_size) { | 331 | 294M | return; | 332 | 294M | } | 333 | 4.87M | if (cur_size > new_size) { | 334 | 371k | erase(item_ptr(new_size), end()); | 335 | 371k | return; | 336 | 371k | } | 337 | 4.50M | if (new_size > capacity()) { | 338 | 255k | change_capacity(new_size); | 339 | 255k | } | 340 | 4.50M | ptrdiff_t increase = new_size - cur_size; | 341 | 4.50M | fill(item_ptr(cur_size), increase); | 342 | 4.50M | _size += increase; | 343 | 4.50M | } |
_ZN9prevectorILj16EhjiE6resizeEj Line | Count | Source | 328 | 29.1M | void resize(size_type new_size) { | 329 | 29.1M | size_type cur_size = size(); | 330 | 29.1M | if (cur_size == new_size) { | 331 | 9.80M | return; | 332 | 9.80M | } | 333 | 19.3M | if (cur_size > new_size) { | 334 | 11.5M | erase(item_ptr(new_size), end()); | 335 | 11.5M | return; | 336 | 11.5M | } | 337 | 7.78M | if (new_size > capacity()) { | 338 | 7.78M | change_capacity(new_size); | 339 | 7.78M | } | 340 | 7.78M | ptrdiff_t increase = new_size - cur_size; | 341 | 7.78M | fill(item_ptr(cur_size), increase); | 342 | 7.78M | _size += increase; | 343 | 7.78M | } |
_ZN9prevectorILj8EijiE6resizeEj Line | Count | Source | 328 | 34.1k | void resize(size_type new_size) { | 329 | 34.1k | size_type cur_size = size(); | 330 | 34.1k | if (cur_size == new_size) { | 331 | 14.8k | return; | 332 | 14.8k | } | 333 | 19.3k | if (cur_size > new_size) { | 334 | 15.5k | erase(item_ptr(new_size), end()); | 335 | 15.5k | return; | 336 | 15.5k | } | 337 | 3.76k | if (new_size > capacity()) { | 338 | 476 | change_capacity(new_size); | 339 | 476 | } | 340 | 3.76k | ptrdiff_t increase = new_size - cur_size; | 341 | 3.76k | fill(item_ptr(cur_size), increase); | 342 | 3.76k | _size += increase; | 343 | 3.76k | } |
_ZN9prevectorILj33EhjiE6resizeEj Line | Count | Source | 328 | 176k | void resize(size_type new_size) { | 329 | 176k | size_type cur_size = size(); | 330 | 176k | if (cur_size == new_size) { | 331 | 2.12k | return; | 332 | 2.12k | } | 333 | 174k | if (cur_size > new_size) { | 334 | 0 | erase(item_ptr(new_size), end()); | 335 | 0 | return; | 336 | 0 | } | 337 | 174k | if (new_size > capacity()) { | 338 | 0 | change_capacity(new_size); | 339 | 0 | } | 340 | 174k | ptrdiff_t increase = new_size - cur_size; | 341 | 174k | fill(item_ptr(cur_size), increase); | 342 | 174k | _size += increase; | 343 | 174k | } |
|
344 | | |
345 | 3.24k | void reserve(size_type new_capacity) { |
346 | 3.24k | if (new_capacity > capacity()) { |
347 | 1.71k | change_capacity(new_capacity); |
348 | 1.71k | } |
349 | 3.24k | } _ZN9prevectorILj28EhjiE7reserveEj Line | Count | Source | 345 | 197 | void reserve(size_type new_capacity) { | 346 | 197 | if (new_capacity > capacity()) { | 347 | 94 | change_capacity(new_capacity); | 348 | 94 | } | 349 | 197 | } |
_ZN9prevectorILj8EijiE7reserveEj Line | Count | Source | 345 | 3.04k | void reserve(size_type new_capacity) { | 346 | 3.04k | if (new_capacity > capacity()) { | 347 | 1.62k | change_capacity(new_capacity); | 348 | 1.62k | } | 349 | 3.04k | } |
|
350 | | |
351 | 34.1M | void shrink_to_fit() { |
352 | 34.1M | change_capacity(size()); |
353 | 34.1M | } _ZN9prevectorILj28EhjiE13shrink_to_fitEv Line | Count | Source | 351 | 34.1M | void shrink_to_fit() { | 352 | 34.1M | change_capacity(size()); | 353 | 34.1M | } |
_ZN9prevectorILj8EijiE13shrink_to_fitEv Line | Count | Source | 351 | 5.09k | void shrink_to_fit() { | 352 | 5.09k | change_capacity(size()); | 353 | 5.09k | } |
|
354 | | |
355 | 300M | void clear() { |
356 | 300M | resize(0); |
357 | 300M | } _ZN9prevectorILj28EhjiE5clearEv Line | Count | Source | 355 | 292M | void clear() { | 356 | 292M | resize(0); | 357 | 292M | } |
_ZN9prevectorILj16EhjiE5clearEv Line | Count | Source | 355 | 8.17M | void clear() { | 356 | 8.17M | resize(0); | 357 | 8.17M | } |
_ZN9prevectorILj8EijiE5clearEv Line | Count | Source | 355 | 26.8k | void clear() { | 356 | 26.8k | resize(0); | 357 | 26.8k | } |
_ZN9prevectorILj33EhjiE5clearEv Line | Count | Source | 355 | 2.12k | void clear() { | 356 | 2.12k | resize(0); | 357 | 2.12k | } |
|
358 | | |
359 | 36.0M | iterator insert(iterator pos, const T& value) { |
360 | 36.0M | size_type p = pos - begin(); |
361 | 36.0M | size_type new_size = size() + 1; |
362 | 36.0M | if (capacity() < new_size) { |
363 | 42.9k | change_capacity(new_size + (new_size >> 1)); |
364 | 42.9k | } |
365 | 36.0M | T* ptr = item_ptr(p); |
366 | 36.0M | T* dst = ptr + 1; |
367 | 36.0M | memmove(dst, ptr, (size() - p) * sizeof(T)); |
368 | 36.0M | _size++; |
369 | 36.0M | new(static_cast<void*>(ptr)) T(value); |
370 | 36.0M | return iterator(ptr); |
371 | 36.0M | } _ZN9prevectorILj28EhjiE6insertENS0_8iteratorERKh Line | Count | Source | 359 | 36.0M | iterator insert(iterator pos, const T& value) { | 360 | 36.0M | size_type p = pos - begin(); | 361 | 36.0M | size_type new_size = size() + 1; | 362 | 36.0M | if (capacity() < new_size) { | 363 | 42.1k | change_capacity(new_size + (new_size >> 1)); | 364 | 42.1k | } | 365 | 36.0M | T* ptr = item_ptr(p); | 366 | 36.0M | T* dst = ptr + 1; | 367 | 36.0M | memmove(dst, ptr, (size() - p) * sizeof(T)); | 368 | 36.0M | _size++; | 369 | 36.0M | new(static_cast<void*>(ptr)) T(value); | 370 | 36.0M | return iterator(ptr); | 371 | 36.0M | } |
_ZN9prevectorILj8EijiE6insertENS0_8iteratorERKi Line | Count | Source | 359 | 11.5k | iterator insert(iterator pos, const T& value) { | 360 | 11.5k | size_type p = pos - begin(); | 361 | 11.5k | size_type new_size = size() + 1; | 362 | 11.5k | if (capacity() < new_size) { | 363 | 804 | change_capacity(new_size + (new_size >> 1)); | 364 | 804 | } | 365 | 11.5k | T* ptr = item_ptr(p); | 366 | 11.5k | T* dst = ptr + 1; | 367 | 11.5k | memmove(dst, ptr, (size() - p) * sizeof(T)); | 368 | 11.5k | _size++; | 369 | 11.5k | new(static_cast<void*>(ptr)) T(value); | 370 | 11.5k | return iterator(ptr); | 371 | 11.5k | } |
|
372 | | |
373 | 7.10k | void insert(iterator pos, size_type count, const T& value) { |
374 | 7.10k | size_type p = pos - begin(); |
375 | 7.10k | size_type new_size = size() + count; |
376 | 7.10k | if (capacity() < new_size) { |
377 | 644 | change_capacity(new_size + (new_size >> 1)); |
378 | 644 | } |
379 | 7.10k | T* ptr = item_ptr(p); |
380 | 7.10k | T* dst = ptr + count; |
381 | 7.10k | memmove(dst, ptr, (size() - p) * sizeof(T)); |
382 | 7.10k | _size += count; |
383 | 7.10k | fill(item_ptr(p), count, value); |
384 | 7.10k | } _ZN9prevectorILj8EijiE6insertENS0_8iteratorEjRKi Line | Count | Source | 373 | 7.10k | void insert(iterator pos, size_type count, const T& value) { | 374 | 7.10k | size_type p = pos - begin(); | 375 | 7.10k | size_type new_size = size() + count; | 376 | 7.10k | if (capacity() < new_size) { | 377 | 644 | change_capacity(new_size + (new_size >> 1)); | 378 | 644 | } | 379 | 7.10k | T* ptr = item_ptr(p); | 380 | 7.10k | T* dst = ptr + count; | 381 | 7.10k | memmove(dst, ptr, (size() - p) * sizeof(T)); | 382 | 7.10k | _size += count; | 383 | 7.10k | fill(item_ptr(p), count, value); | 384 | 7.10k | } |
Unexecuted instantiation: _ZN9prevectorILj28EhjiE6insertENS0_8iteratorEjRKh |
385 | | |
386 | | template <std::input_iterator InputIterator> |
387 | 46.2M | void insert(iterator pos, InputIterator first, InputIterator last) { |
388 | 46.2M | size_type p = pos - begin(); |
389 | 46.2M | difference_type count = last - first; |
390 | 46.2M | size_type new_size = size() + count; |
391 | 46.2M | if (capacity() < new_size) { |
392 | 1.94M | change_capacity(new_size + (new_size >> 1)); |
393 | 1.94M | } |
394 | 46.2M | T* ptr = item_ptr(p); |
395 | 46.2M | T* dst = ptr + count; |
396 | 46.2M | memmove(dst, ptr, (size() - p) * sizeof(T)); |
397 | 46.2M | _size += count; |
398 | 46.2M | fill(ptr, first, last); |
399 | 46.2M | } _ZN9prevectorILj28EhjiE6insertITkSt14input_iteratorPKhEEvNS0_8iteratorET_S5_ Line | Count | Source | 387 | 6.46k | void insert(iterator pos, InputIterator first, InputIterator last) { | 388 | 6.46k | size_type p = pos - begin(); | 389 | 6.46k | difference_type count = last - first; | 390 | 6.46k | size_type new_size = size() + count; | 391 | 6.46k | if (capacity() < new_size) { | 392 | 285 | change_capacity(new_size + (new_size >> 1)); | 393 | 285 | } | 394 | 6.46k | T* ptr = item_ptr(p); | 395 | 6.46k | T* dst = ptr + count; | 396 | 6.46k | memmove(dst, ptr, (size() - p) * sizeof(T)); | 397 | 6.46k | _size += count; | 398 | 6.46k | fill(ptr, first, last); | 399 | 6.46k | } |
_ZN9prevectorILj28EhjiE6insertITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvNS0_8iteratorET_SA_ Line | Count | Source | 387 | 16.4M | void insert(iterator pos, InputIterator first, InputIterator last) { | 388 | 16.4M | size_type p = pos - begin(); | 389 | 16.4M | difference_type count = last - first; | 390 | 16.4M | size_type new_size = size() + count; | 391 | 16.4M | if (capacity() < new_size) { | 392 | 1.15M | change_capacity(new_size + (new_size >> 1)); | 393 | 1.15M | } | 394 | 16.4M | T* ptr = item_ptr(p); | 395 | 16.4M | T* dst = ptr + count; | 396 | 16.4M | memmove(dst, ptr, (size() - p) * sizeof(T)); | 397 | 16.4M | _size += count; | 398 | 16.4M | fill(ptr, first, last); | 399 | 16.4M | } |
_ZN9prevectorILj28EhjiE6insertITkSt14input_iteratorNS0_8iteratorEEEvS2_T_S3_ Line | Count | Source | 387 | 749k | void insert(iterator pos, InputIterator first, InputIterator last) { | 388 | 749k | size_type p = pos - begin(); | 389 | 749k | difference_type count = last - first; | 390 | 749k | size_type new_size = size() + count; | 391 | 749k | if (capacity() < new_size) { | 392 | 330k | change_capacity(new_size + (new_size >> 1)); | 393 | 330k | } | 394 | 749k | T* ptr = item_ptr(p); | 395 | 749k | T* dst = ptr + count; | 396 | 749k | memmove(dst, ptr, (size() - p) * sizeof(T)); | 397 | 749k | _size += count; | 398 | 749k | fill(ptr, first, last); | 399 | 749k | } |
_ZN9prevectorILj8EijiE6insertITkSt14input_iteratorPiEEvNS0_8iteratorET_S4_ Line | Count | Source | 387 | 5.19k | void insert(iterator pos, InputIterator first, InputIterator last) { | 388 | 5.19k | size_type p = pos - begin(); | 389 | 5.19k | difference_type count = last - first; | 390 | 5.19k | size_type new_size = size() + count; | 391 | 5.19k | if (capacity() < new_size) { | 392 | 454 | change_capacity(new_size + (new_size >> 1)); | 393 | 454 | } | 394 | 5.19k | T* ptr = item_ptr(p); | 395 | 5.19k | T* dst = ptr + count; | 396 | 5.19k | memmove(dst, ptr, (size() - p) * sizeof(T)); | 397 | 5.19k | _size += count; | 398 | 5.19k | fill(ptr, first, last); | 399 | 5.19k | } |
_ZN9prevectorILj28EhjiE6insertITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEEvNS0_8iteratorET_SA_ Line | Count | Source | 387 | 2.82M | void insert(iterator pos, InputIterator first, InputIterator last) { | 388 | 2.82M | size_type p = pos - begin(); | 389 | 2.82M | difference_type count = last - first; | 390 | 2.82M | size_type new_size = size() + count; | 391 | 2.82M | if (capacity() < new_size) { | 392 | 61.6k | change_capacity(new_size + (new_size >> 1)); | 393 | 61.6k | } | 394 | 2.82M | T* ptr = item_ptr(p); | 395 | 2.82M | T* dst = ptr + count; | 396 | 2.82M | memmove(dst, ptr, (size() - p) * sizeof(T)); | 397 | 2.82M | _size += count; | 398 | 2.82M | fill(ptr, first, last); | 399 | 2.82M | } |
_ZN9prevectorILj35EhjiE6insertITkSt14input_iteratorPhEEvNS0_8iteratorET_S4_ Line | Count | Source | 387 | 121k | void insert(iterator pos, InputIterator first, InputIterator last) { | 388 | 121k | size_type p = pos - begin(); | 389 | 121k | difference_type count = last - first; | 390 | 121k | size_type new_size = size() + count; | 391 | 121k | if (capacity() < new_size) { | 392 | 0 | change_capacity(new_size + (new_size >> 1)); | 393 | 0 | } | 394 | 121k | T* ptr = item_ptr(p); | 395 | 121k | T* dst = ptr + count; | 396 | 121k | memmove(dst, ptr, (size() - p) * sizeof(T)); | 397 | 121k | _size += count; | 398 | 121k | fill(ptr, first, last); | 399 | 121k | } |
_ZN9prevectorILj35EhjiE6insertITkSt14input_iteratorPKhEEvNS0_8iteratorET_S5_ Line | Count | Source | 387 | 121k | void insert(iterator pos, InputIterator first, InputIterator last) { | 388 | 121k | size_type p = pos - begin(); | 389 | 121k | difference_type count = last - first; | 390 | 121k | size_type new_size = size() + count; | 391 | 121k | if (capacity() < new_size) { | 392 | 0 | change_capacity(new_size + (new_size >> 1)); | 393 | 0 | } | 394 | 121k | T* ptr = item_ptr(p); | 395 | 121k | T* dst = ptr + count; | 396 | 121k | memmove(dst, ptr, (size() - p) * sizeof(T)); | 397 | 121k | _size += count; | 398 | 121k | fill(ptr, first, last); | 399 | 121k | } |
_ZN9prevectorILj28EhjiE6insertITkSt14input_iteratorNS0_14const_iteratorEEEvNS0_8iteratorET_S4_ Line | Count | Source | 387 | 25.9M | void insert(iterator pos, InputIterator first, InputIterator last) { | 388 | 25.9M | size_type p = pos - begin(); | 389 | 25.9M | difference_type count = last - first; | 390 | 25.9M | size_type new_size = size() + count; | 391 | 25.9M | if (capacity() < new_size) { | 392 | 399k | change_capacity(new_size + (new_size >> 1)); | 393 | 399k | } | 394 | 25.9M | T* ptr = item_ptr(p); | 395 | 25.9M | T* dst = ptr + count; | 396 | 25.9M | memmove(dst, ptr, (size() - p) * sizeof(T)); | 397 | 25.9M | _size += count; | 398 | 25.9M | fill(ptr, first, last); | 399 | 25.9M | } |
|
400 | | |
401 | 5.84M | inline void resize_uninitialized(size_type new_size) { |
402 | | // resize_uninitialized changes the size of the prevector but does not initialize it. |
403 | | // If size < new_size, the added elements must be initialized explicitly. |
404 | 5.84M | if (capacity() < new_size) { |
405 | 1.74M | change_capacity(new_size); |
406 | 1.74M | _size += new_size - size(); |
407 | 1.74M | return; |
408 | 1.74M | } |
409 | 4.09M | if (new_size < size()) { |
410 | 1.68k | erase(item_ptr(new_size), end()); |
411 | 4.08M | } else { |
412 | 4.08M | _size += new_size - size(); |
413 | 4.08M | } |
414 | 4.09M | } _ZN9prevectorILj28EhjiE20resize_uninitializedEj Line | Count | Source | 401 | 5.83M | inline void resize_uninitialized(size_type new_size) { | 402 | | // resize_uninitialized changes the size of the prevector but does not initialize it. | 403 | | // If size < new_size, the added elements must be initialized explicitly. | 404 | 5.83M | if (capacity() < new_size) { | 405 | 1.74M | change_capacity(new_size); | 406 | 1.74M | _size += new_size - size(); | 407 | 1.74M | return; | 408 | 1.74M | } | 409 | 4.08M | if (new_size < size()) { | 410 | 0 | erase(item_ptr(new_size), end()); | 411 | 4.08M | } else { | 412 | 4.08M | _size += new_size - size(); | 413 | 4.08M | } | 414 | 4.08M | } |
_ZN9prevectorILj8EijiE20resize_uninitializedEj Line | Count | Source | 401 | 4.84k | inline void resize_uninitialized(size_type new_size) { | 402 | | // resize_uninitialized changes the size of the prevector but does not initialize it. | 403 | | // If size < new_size, the added elements must be initialized explicitly. | 404 | 4.84k | if (capacity() < new_size) { | 405 | 842 | change_capacity(new_size); | 406 | 842 | _size += new_size - size(); | 407 | 842 | return; | 408 | 842 | } | 409 | 4.00k | if (new_size < size()) { | 410 | 1.68k | erase(item_ptr(new_size), end()); | 411 | 2.31k | } else { | 412 | 2.31k | _size += new_size - size(); | 413 | 2.31k | } | 414 | 4.00k | } |
|
415 | | |
416 | 2.40k | iterator erase(iterator pos) { |
417 | 2.40k | return erase(pos, pos + 1); |
418 | 2.40k | } _ZN9prevectorILj8EijiE5eraseENS0_8iteratorE Line | Count | Source | 416 | 2.38k | iterator erase(iterator pos) { | 417 | 2.38k | return erase(pos, pos + 1); | 418 | 2.38k | } |
_ZN9prevectorILj33EhjiE5eraseENS0_8iteratorE Line | Count | Source | 416 | 14 | iterator erase(iterator pos) { | 417 | 14 | return erase(pos, pos + 1); | 418 | 14 | } |
|
419 | | |
420 | 11.9M | iterator erase(iterator first, iterator last) { |
421 | | // Erase is not allowed to the change the object's capacity. That means |
422 | | // that when starting with an indirectly allocated prevector with |
423 | | // size and capacity > N, the result may be a still indirectly allocated |
424 | | // prevector with size <= N and capacity > N. A shrink_to_fit() call is |
425 | | // necessary to switch to the (more efficient) directly allocated |
426 | | // representation (with capacity N and size <= N). |
427 | 11.9M | iterator p = first; |
428 | 11.9M | char* endp = (char*)&(*end()); |
429 | 11.9M | _size -= last - p; |
430 | 11.9M | memmove(&(*first), &(*last), endp - ((char*)(&(*last)))); |
431 | 11.9M | return first; |
432 | 11.9M | } _ZN9prevectorILj28EhjiE5eraseENS0_8iteratorES1_ Line | Count | Source | 420 | 371k | iterator erase(iterator first, iterator last) { | 421 | | // Erase is not allowed to the change the object's capacity. That means | 422 | | // that when starting with an indirectly allocated prevector with | 423 | | // size and capacity > N, the result may be a still indirectly allocated | 424 | | // prevector with size <= N and capacity > N. A shrink_to_fit() call is | 425 | | // necessary to switch to the (more efficient) directly allocated | 426 | | // representation (with capacity N and size <= N). | 427 | 371k | iterator p = first; | 428 | 371k | char* endp = (char*)&(*end()); | 429 | 371k | _size -= last - p; | 430 | 371k | memmove(&(*first), &(*last), endp - ((char*)(&(*last)))); | 431 | 371k | return first; | 432 | 371k | } |
_ZN9prevectorILj16EhjiE5eraseENS0_8iteratorES1_ Line | Count | Source | 420 | 11.5M | iterator erase(iterator first, iterator last) { | 421 | | // Erase is not allowed to the change the object's capacity. That means | 422 | | // that when starting with an indirectly allocated prevector with | 423 | | // size and capacity > N, the result may be a still indirectly allocated | 424 | | // prevector with size <= N and capacity > N. A shrink_to_fit() call is | 425 | | // necessary to switch to the (more efficient) directly allocated | 426 | | // representation (with capacity N and size <= N). | 427 | 11.5M | iterator p = first; | 428 | 11.5M | char* endp = (char*)&(*end()); | 429 | 11.5M | _size -= last - p; | 430 | 11.5M | memmove(&(*first), &(*last), endp - ((char*)(&(*last)))); | 431 | 11.5M | return first; | 432 | 11.5M | } |
_ZN9prevectorILj8EijiE5eraseENS0_8iteratorES1_ Line | Count | Source | 420 | 28.3k | iterator erase(iterator first, iterator last) { | 421 | | // Erase is not allowed to the change the object's capacity. That means | 422 | | // that when starting with an indirectly allocated prevector with | 423 | | // size and capacity > N, the result may be a still indirectly allocated | 424 | | // prevector with size <= N and capacity > N. A shrink_to_fit() call is | 425 | | // necessary to switch to the (more efficient) directly allocated | 426 | | // representation (with capacity N and size <= N). | 427 | 28.3k | iterator p = first; | 428 | 28.3k | char* endp = (char*)&(*end()); | 429 | 28.3k | _size -= last - p; | 430 | 28.3k | memmove(&(*first), &(*last), endp - ((char*)(&(*last)))); | 431 | 28.3k | return first; | 432 | 28.3k | } |
_ZN9prevectorILj33EhjiE5eraseENS0_8iteratorES1_ Line | Count | Source | 420 | 14 | iterator erase(iterator first, iterator last) { | 421 | | // Erase is not allowed to the change the object's capacity. That means | 422 | | // that when starting with an indirectly allocated prevector with | 423 | | // size and capacity > N, the result may be a still indirectly allocated | 424 | | // prevector with size <= N and capacity > N. A shrink_to_fit() call is | 425 | | // necessary to switch to the (more efficient) directly allocated | 426 | | // representation (with capacity N and size <= N). | 427 | 14 | iterator p = first; | 428 | 14 | char* endp = (char*)&(*end()); | 429 | 14 | _size -= last - p; | 430 | 14 | memmove(&(*first), &(*last), endp - ((char*)(&(*last)))); | 431 | 14 | return first; | 432 | 14 | } |
|
433 | | |
434 | | template<typename... Args> |
435 | 699k | void emplace_back(Args&&... args) { |
436 | 699k | size_type new_size = size() + 1; |
437 | 699k | if (capacity() < new_size) { |
438 | 5.46k | change_capacity(new_size + (new_size >> 1)); |
439 | 5.46k | } |
440 | 699k | new(item_ptr(size())) T(std::forward<Args>(args)...); |
441 | 699k | _size++; |
442 | 699k | } _ZN9prevectorILj28EhjiE12emplace_backIJRKhEEEvDpOT_ Line | Count | Source | 435 | 696k | void emplace_back(Args&&... args) { | 436 | 696k | size_type new_size = size() + 1; | 437 | 696k | if (capacity() < new_size) { | 438 | 5.05k | change_capacity(new_size + (new_size >> 1)); | 439 | 5.05k | } | 440 | 696k | new(item_ptr(size())) T(std::forward<Args>(args)...); | 441 | 696k | _size++; | 442 | 696k | } |
_ZN9prevectorILj8EijiE12emplace_backIJRKiEEEvDpOT_ Line | Count | Source | 435 | 3.12k | void emplace_back(Args&&... args) { | 436 | 3.12k | size_type new_size = size() + 1; | 437 | 3.12k | if (capacity() < new_size) { | 438 | 412 | change_capacity(new_size + (new_size >> 1)); | 439 | 412 | } | 440 | 3.12k | new(item_ptr(size())) T(std::forward<Args>(args)...); | 441 | 3.12k | _size++; | 442 | 3.12k | } |
|
443 | | |
444 | 699k | void push_back(const T& value) { |
445 | 699k | emplace_back(value); |
446 | 699k | } _ZN9prevectorILj28EhjiE9push_backERKh Line | Count | Source | 444 | 696k | void push_back(const T& value) { | 445 | 696k | emplace_back(value); | 446 | 696k | } |
_ZN9prevectorILj8EijiE9push_backERKi Line | Count | Source | 444 | 3.12k | void push_back(const T& value) { | 445 | 3.12k | emplace_back(value); | 446 | 3.12k | } |
|
447 | | |
448 | 3.48k | void pop_back() { |
449 | 3.48k | erase(end() - 1, end()); |
450 | 3.48k | } |
451 | | |
452 | | T& front() { |
453 | | return *item_ptr(0); |
454 | | } |
455 | | |
456 | | const T& front() const { |
457 | | return *item_ptr(0); |
458 | | } |
459 | | |
460 | 11.2k | T& back() { |
461 | 11.2k | return *item_ptr(size() - 1); |
462 | 11.2k | } |
463 | | |
464 | 2.76M | const T& back() const { |
465 | 2.76M | return *item_ptr(size() - 1); |
466 | 2.76M | } |
467 | | |
468 | | void swap(prevector<N, T, Size, Diff>& other) noexcept |
469 | 4.04k | { |
470 | 4.04k | std::swap(_union, other._union); |
471 | 4.04k | std::swap(_size, other._size); |
472 | 4.04k | } |
473 | | |
474 | 1.51G | ~prevector() { |
475 | 1.51G | if (!is_direct()) { |
476 | 773M | free(_union.indirect_contents.indirect); |
477 | 773M | _union.indirect_contents.indirect = nullptr; |
478 | 773M | } |
479 | 1.51G | } _ZN9prevectorILj16EhjiED2Ev Line | Count | Source | 474 | 237M | ~prevector() { | 475 | 237M | if (!is_direct()) { | 476 | 75.8M | free(_union.indirect_contents.indirect); | 477 | 75.8M | _union.indirect_contents.indirect = nullptr; | 478 | 75.8M | } | 479 | 237M | } |
_ZN9prevectorILj28EhjiED2Ev Line | Count | Source | 474 | 1.27G | ~prevector() { | 475 | 1.27G | if (!is_direct()) { | 476 | 698M | free(_union.indirect_contents.indirect); | 477 | 698M | _union.indirect_contents.indirect = nullptr; | 478 | 698M | } | 479 | 1.27G | } |
_ZN9prevectorILj33EhjiED2Ev Line | Count | Source | 474 | 1.97M | ~prevector() { | 475 | 1.97M | if (!is_direct()) { | 476 | 517 | free(_union.indirect_contents.indirect); | 477 | 517 | _union.indirect_contents.indirect = nullptr; | 478 | 517 | } | 479 | 1.97M | } |
_ZN9prevectorILj8EijiED2Ev Line | Count | Source | 474 | 644 | ~prevector() { | 475 | 644 | if (!is_direct()) { | 476 | 249 | free(_union.indirect_contents.indirect); | 477 | 249 | _union.indirect_contents.indirect = nullptr; | 478 | 249 | } | 479 | 644 | } |
_ZN9prevectorILj35EhjiED2Ev Line | Count | Source | 474 | 121k | ~prevector() { | 475 | 121k | if (!is_direct()) { | 476 | 0 | free(_union.indirect_contents.indirect); | 477 | 0 | _union.indirect_contents.indirect = nullptr; | 478 | 0 | } | 479 | 121k | } |
|
480 | | |
481 | 42.3M | bool operator==(const prevector<N, T, Size, Diff>& other) const { |
482 | 42.3M | if (other.size() != size()) { |
483 | 180 | return false; |
484 | 180 | } |
485 | 42.3M | const_iterator b1 = begin(); |
486 | 42.3M | const_iterator b2 = other.begin(); |
487 | 42.3M | const_iterator e1 = end(); |
488 | 772M | while (b1 != e1) { |
489 | 738M | if ((*b1) != (*b2)) { |
490 | 8.64M | return false; |
491 | 8.64M | } |
492 | 729M | ++b1; |
493 | 729M | ++b2; |
494 | 729M | } |
495 | 33.7M | return true; |
496 | 42.3M | } _ZNK9prevectorILj28EhjiEeqERKS0_ Line | Count | Source | 481 | 9.08M | bool operator==(const prevector<N, T, Size, Diff>& other) const { | 482 | 9.08M | if (other.size() != size()) { | 483 | 180 | return false; | 484 | 180 | } | 485 | 9.08M | const_iterator b1 = begin(); | 486 | 9.08M | const_iterator b2 = other.begin(); | 487 | 9.08M | const_iterator e1 = end(); | 488 | 233M | while (b1 != e1) { | 489 | 224M | if ((*b1) != (*b2)) { | 490 | 10 | return false; | 491 | 10 | } | 492 | 224M | ++b1; | 493 | 224M | ++b2; | 494 | 224M | } | 495 | 9.08M | return true; | 496 | 9.08M | } |
_ZNK9prevectorILj8EijiEeqERKS0_ Line | Count | Source | 481 | 322 | bool operator==(const prevector<N, T, Size, Diff>& other) const { | 482 | 322 | if (other.size() != size()) { | 483 | 0 | return false; | 484 | 0 | } | 485 | 322 | const_iterator b1 = begin(); | 486 | 322 | const_iterator b2 = other.begin(); | 487 | 322 | const_iterator e1 = end(); | 488 | 1.07M | while (b1 != e1) { | 489 | 1.07M | if ((*b1) != (*b2)) { | 490 | 0 | return false; | 491 | 0 | } | 492 | 1.07M | ++b1; | 493 | 1.07M | ++b2; | 494 | 1.07M | } | 495 | 322 | return true; | 496 | 322 | } |
_ZNK9prevectorILj16EhjiEeqERKS0_ Line | Count | Source | 481 | 33.2M | bool operator==(const prevector<N, T, Size, Diff>& other) const { | 482 | 33.2M | if (other.size() != size()) { | 483 | 0 | return false; | 484 | 0 | } | 485 | 33.2M | const_iterator b1 = begin(); | 486 | 33.2M | const_iterator b2 = other.begin(); | 487 | 33.2M | const_iterator e1 = end(); | 488 | 537M | while (b1 != e1) { | 489 | 512M | if ((*b1) != (*b2)) { | 490 | 8.64M | return false; | 491 | 8.64M | } | 492 | 504M | ++b1; | 493 | 504M | ++b2; | 494 | 504M | } | 495 | 24.6M | return true; | 496 | 33.2M | } |
|
497 | | |
498 | 57.4k | bool operator!=(const prevector<N, T, Size, Diff>& other) const { |
499 | 57.4k | return !(*this == other); |
500 | 57.4k | } |
501 | | |
502 | 135M | bool operator<(const prevector<N, T, Size, Diff>& other) const { |
503 | 135M | if (size() < other.size()) { |
504 | 2.20M | return true; |
505 | 2.20M | } |
506 | 133M | if (size() > other.size()) { |
507 | 1.32M | return false; |
508 | 1.32M | } |
509 | 132M | const_iterator b1 = begin(); |
510 | 132M | const_iterator b2 = other.begin(); |
511 | 132M | const_iterator e1 = end(); |
512 | 1.02G | while (b1 != e1) { |
513 | 997M | if ((*b1) < (*b2)) { |
514 | 61.6M | return true; |
515 | 61.6M | } |
516 | 935M | if ((*b2) < (*b1)) { |
517 | 44.3M | return false; |
518 | 44.3M | } |
519 | 891M | ++b1; |
520 | 891M | ++b2; |
521 | 891M | } |
522 | 26.2M | return false; |
523 | 132M | } _ZNK9prevectorILj28EhjiEltERKS0_ Line | Count | Source | 502 | 132M | bool operator<(const prevector<N, T, Size, Diff>& other) const { | 503 | 132M | if (size() < other.size()) { | 504 | 2.20M | return true; | 505 | 2.20M | } | 506 | 129M | if (size() > other.size()) { | 507 | 1.32M | return false; | 508 | 1.32M | } | 509 | 128M | const_iterator b1 = begin(); | 510 | 128M | const_iterator b2 = other.begin(); | 511 | 128M | const_iterator e1 = end(); | 512 | 1.00G | while (b1 != e1) { | 513 | 975M | if ((*b1) < (*b2)) { | 514 | 59.8M | return true; | 515 | 59.8M | } | 516 | 915M | if ((*b2) < (*b1)) { | 517 | 43.5M | return false; | 518 | 43.5M | } | 519 | 872M | ++b1; | 520 | 872M | ++b2; | 521 | 872M | } | 522 | 25.2M | return false; | 523 | 128M | } |
_ZNK9prevectorILj16EhjiEltERKS0_ Line | Count | Source | 502 | 3.66M | bool operator<(const prevector<N, T, Size, Diff>& other) const { | 503 | 3.66M | if (size() < other.size()) { | 504 | 0 | return true; | 505 | 0 | } | 506 | 3.66M | if (size() > other.size()) { | 507 | 0 | return false; | 508 | 0 | } | 509 | 3.66M | const_iterator b1 = begin(); | 510 | 3.66M | const_iterator b2 = other.begin(); | 511 | 3.66M | const_iterator e1 = end(); | 512 | 23.2M | while (b1 != e1) { | 513 | 22.2M | if ((*b1) < (*b2)) { | 514 | 1.84M | return true; | 515 | 1.84M | } | 516 | 20.3M | if ((*b2) < (*b1)) { | 517 | 797k | return false; | 518 | 797k | } | 519 | 19.5M | ++b1; | 520 | 19.5M | ++b2; | 521 | 19.5M | } | 522 | 1.02M | return false; | 523 | 3.66M | } |
|
524 | | |
525 | 30.6M | size_t allocated_memory() const { |
526 | 30.6M | if (is_direct()) { |
527 | 14.4M | return 0; |
528 | 16.2M | } else { |
529 | 16.2M | return ((size_t)(sizeof(T))) * _union.indirect_contents.capacity; |
530 | 16.2M | } |
531 | 30.6M | } |
532 | | |
533 | 28.0M | value_type* data() { |
534 | 28.0M | return item_ptr(0); |
535 | 28.0M | } _ZN9prevectorILj33EhjiE4dataEv Line | Count | Source | 533 | 439k | value_type* data() { | 534 | 439k | return item_ptr(0); | 535 | 439k | } |
_ZN9prevectorILj28EhjiE4dataEv Line | Count | Source | 533 | 6.53M | value_type* data() { | 534 | 6.53M | return item_ptr(0); | 535 | 6.53M | } |
_ZN9prevectorILj16EhjiE4dataEv Line | Count | Source | 533 | 20.9M | value_type* data() { | 534 | 20.9M | return item_ptr(0); | 535 | 20.9M | } |
_ZN9prevectorILj35EhjiE4dataEv Line | Count | Source | 533 | 121k | value_type* data() { | 534 | 121k | return item_ptr(0); | 535 | 121k | } |
|
536 | | |
537 | 1.06G | const value_type* data() const { |
538 | 1.06G | return item_ptr(0); |
539 | 1.06G | } _ZNK9prevectorILj28EhjiE4dataEv Line | Count | Source | 537 | 618M | const value_type* data() const { | 538 | 618M | return item_ptr(0); | 539 | 618M | } |
_ZNK9prevectorILj16EhjiE4dataEv Line | Count | Source | 537 | 442M | const value_type* data() const { | 538 | 442M | return item_ptr(0); | 539 | 442M | } |
_ZNK9prevectorILj33EhjiE4dataEv Line | Count | Source | 537 | 264k | const value_type* data() const { | 538 | 264k | return item_ptr(0); | 539 | 264k | } |
|
540 | | }; |
541 | | |
542 | | #endif // BITCOIN_PREVECTOR_H |