/root/bitcoin/src/util/bitset.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) 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_UTIL_BITSET_H |
6 | | #define BITCOIN_UTIL_BITSET_H |
7 | | |
8 | | #include <util/check.h> |
9 | | |
10 | | #include <array> |
11 | | #include <bit> |
12 | | #include <cstdint> |
13 | | #include <limits> |
14 | | #include <type_traits> |
15 | | |
16 | | /* This file provides data types similar to std::bitset, but adds the following functionality: |
17 | | * |
18 | | * - Efficient iteration over all set bits (compatible with range-based for loops). |
19 | | * - Efficient search for the first and last set bit (First() and Last()). |
20 | | * - Efficient set subtraction: (a - b) implements "a and not b". |
21 | | * - Efficient non-strict subset/superset testing: IsSubsetOf() and IsSupersetOf(). |
22 | | * - Efficient set overlap testing: a.Overlaps(b) |
23 | | * - Efficient construction of set containing 0..N-1 (S::Fill). |
24 | | * - Efficient construction of a single set (S::Singleton). |
25 | | * - Construction from initializer lists. |
26 | | * |
27 | | * Other differences: |
28 | | * - BitSet<N> is a bitset that supports at least N elements, but may support more (Size() reports |
29 | | * the actual number). Because the actual number is unpredictable, there are no operations that |
30 | | * affect all positions (like std::bitset's operator~, flip(), or all()). |
31 | | * - Various other unimplemented features. |
32 | | */ |
33 | | |
34 | | namespace bitset_detail { |
35 | | |
36 | | /** Count the number of bits set in an unsigned integer type. */ |
37 | | template<typename I> |
38 | | unsigned inline constexpr PopCount(I v) |
39 | 0 | { |
40 | 0 | static_assert(std::is_integral_v<I> && std::is_unsigned_v<I> && std::numeric_limits<I>::radix == 2); |
41 | 0 | constexpr auto BITS = std::numeric_limits<I>::digits; |
42 | | // Algorithms from https://en.wikipedia.org/wiki/Hamming_weight#Efficient_implementation. |
43 | | // These seem to be faster than std::popcount when compiling for non-SSE4 on x86_64. |
44 | 0 | if constexpr (BITS <= 32) { |
45 | 0 | v -= (v >> 1) & 0x55555555; |
46 | 0 | v = (v & 0x33333333) + ((v >> 2) & 0x33333333); |
47 | 0 | v = (v + (v >> 4)) & 0x0f0f0f0f; |
48 | 0 | if constexpr (BITS > 8) v += v >> 8; |
49 | 0 | if constexpr (BITS > 16) v += v >> 16; |
50 | 0 | return v & 0x3f; |
51 | 0 | } else { |
52 | 0 | static_assert(BITS <= 64); |
53 | 0 | v -= (v >> 1) & 0x5555555555555555; |
54 | 0 | v = (v & 0x3333333333333333) + ((v >> 2) & 0x3333333333333333); |
55 | 0 | v = (v + (v >> 4)) & 0x0f0f0f0f0f0f0f0f; |
56 | 0 | return (v * uint64_t{0x0101010101010101}) >> 56; |
57 | 0 | } |
58 | 0 | } Unexecuted instantiation: _ZN13bitset_detail8PopCountItEEjT_ Unexecuted instantiation: _ZN13bitset_detail8PopCountIjEEjT_ Unexecuted instantiation: _ZN13bitset_detail8PopCountImEEjT_ |
59 | | |
60 | | /** A bitset implementation backed by a single integer of type I. */ |
61 | | template<typename I> |
62 | | class IntBitSet |
63 | | { |
64 | | // Only binary, unsigned, integer, types allowed. |
65 | | static_assert(std::is_integral_v<I> && std::is_unsigned_v<I> && std::numeric_limits<I>::radix == 2); |
66 | | /** The maximum number of bits this bitset supports. */ |
67 | | static constexpr unsigned MAX_SIZE = std::numeric_limits<I>::digits; |
68 | | /** Integer whose bits represent this bitset. */ |
69 | | I m_val; |
70 | | /** Internal constructor with a given integer as contents. */ |
71 | 0 | IntBitSet(I val) noexcept : m_val{val} {} Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItEC2Et Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjEC2Ej Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImEC2Em |
72 | | /** Dummy type to return using end(). Only used for comparing with Iterator. */ |
73 | | class IteratorEnd |
74 | | { |
75 | | friend class IntBitSet; |
76 | | constexpr IteratorEnd() = default; |
77 | | public: |
78 | | constexpr IteratorEnd(const IteratorEnd&) = default; |
79 | | }; |
80 | | /** Iterator type returned by begin(), which efficiently iterates all 1 positions. */ |
81 | | class Iterator |
82 | | { |
83 | | friend class IntBitSet; |
84 | | I m_val; /**< The original integer's remaining bits. */ |
85 | | unsigned m_pos; /** Last reported 1 position (if m_pos != 0). */ |
86 | 0 | constexpr Iterator(I val) noexcept : m_val(val), m_pos(0) |
87 | 0 | { |
88 | 0 | if (m_val != 0) m_pos = std::countr_zero(m_val); |
89 | 0 | } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItE8IteratorC2Et Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjE8IteratorC2Ej Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImE8IteratorC2Em |
90 | | public: |
91 | | /** Do not allow external code to construct an Iterator. */ |
92 | | Iterator() = delete; |
93 | | // Copying is allowed. |
94 | | constexpr Iterator(const Iterator&) noexcept = default; |
95 | | constexpr Iterator& operator=(const Iterator&) noexcept = default; |
96 | | /** Test whether we are done (can only compare with IteratorEnd). */ |
97 | | constexpr friend bool operator==(const Iterator& a, const IteratorEnd&) noexcept |
98 | 0 | { |
99 | 0 | return a.m_val == 0; |
100 | 0 | } Unexecuted instantiation: _ZN13bitset_detaileqERKNS_9IntBitSetItE8IteratorERKNS1_11IteratorEndE Unexecuted instantiation: _ZN13bitset_detaileqERKNS_9IntBitSetIjE8IteratorERKNS1_11IteratorEndE Unexecuted instantiation: _ZN13bitset_detaileqERKNS_9IntBitSetImE8IteratorERKNS1_11IteratorEndE |
101 | | /** Progress to the next 1 bit (only if != IteratorEnd). */ |
102 | | constexpr Iterator& operator++() noexcept |
103 | 0 | { |
104 | 0 | Assume(m_val != 0); |
105 | 0 | m_val &= m_val - I{1U}; |
106 | 0 | if (m_val != 0) m_pos = std::countr_zero(m_val); |
107 | 0 | return *this; |
108 | 0 | } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItE8IteratorppEv Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjE8IteratorppEv Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImE8IteratorppEv |
109 | | /** Get the current bit position (only if != IteratorEnd). */ |
110 | | constexpr unsigned operator*() const noexcept |
111 | 0 | { |
112 | 0 | Assume(m_val != 0); |
113 | 0 | return m_pos; |
114 | 0 | } Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetItE8IteratordeEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetIjE8IteratordeEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetImE8IteratordeEv |
115 | | }; |
116 | | |
117 | | public: |
118 | | /** Construct an all-zero bitset. */ |
119 | 0 | constexpr IntBitSet() noexcept : m_val{0} {} Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItEC2Ev Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjEC2Ev Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImEC2Ev |
120 | | /** Copy construct a bitset. */ |
121 | | constexpr IntBitSet(const IntBitSet&) noexcept = default; |
122 | | /** Construct from a list of values. */ |
123 | 0 | constexpr IntBitSet(std::initializer_list<unsigned> ilist) noexcept : m_val(0) |
124 | 0 | { |
125 | 0 | for (auto pos : ilist) Set(pos); |
126 | 0 | } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItEC2ESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjEC2ESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImEC2ESt16initializer_listIjE |
127 | | /** Copy assign a bitset. */ |
128 | | constexpr IntBitSet& operator=(const IntBitSet&) noexcept = default; |
129 | | /** Assign from a list of positions (which will be made true, all others false). */ |
130 | | constexpr IntBitSet& operator=(std::initializer_list<unsigned> ilist) noexcept |
131 | 0 | { |
132 | 0 | m_val = 0; |
133 | 0 | for (auto pos : ilist) Set(pos); |
134 | 0 | return *this; |
135 | 0 | } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItEaSESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjEaSESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImEaSESt16initializer_listIjE |
136 | | /** Construct a bitset with the singleton i. */ |
137 | | static constexpr IntBitSet Singleton(unsigned i) noexcept |
138 | 0 | { |
139 | 0 | Assume(i < MAX_SIZE); |
140 | 0 | return IntBitSet(I(1U) << i); |
141 | 0 | } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItE9SingletonEj Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjE9SingletonEj Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImE9SingletonEj |
142 | | /** Construct a bitset with bits 0..count-1 (inclusive) set to 1. */ |
143 | | static constexpr IntBitSet Fill(unsigned count) noexcept |
144 | 0 | { |
145 | 0 | IntBitSet ret; |
146 | 0 | Assume(count <= MAX_SIZE); |
147 | 0 | if (count) ret.m_val = I(~I{0}) >> (MAX_SIZE - count); |
148 | 0 | return ret; |
149 | 0 | } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItE4FillEj Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjE4FillEj Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImE4FillEj |
150 | | /** Set a bit to 1. */ |
151 | | constexpr void Set(unsigned pos) noexcept |
152 | 0 | { |
153 | 0 | Assume(pos < MAX_SIZE); |
154 | 0 | m_val |= I{1U} << pos; |
155 | 0 | } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItE3SetEj Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjE3SetEj Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImE3SetEj |
156 | | /** Set a bit to the specified value. */ |
157 | | constexpr void Set(unsigned pos, bool val) noexcept |
158 | 0 | { |
159 | 0 | Assume(pos < MAX_SIZE); |
160 | 0 | m_val = (m_val & ~I(I{1U} << pos)) | (I(val) << pos); |
161 | 0 | } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItE3SetEjb Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjE3SetEjb Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImE3SetEjb |
162 | | /** Set a bit to 0. */ |
163 | | constexpr void Reset(unsigned pos) noexcept |
164 | 0 | { |
165 | 0 | Assume(pos < MAX_SIZE); |
166 | 0 | m_val &= ~I(I{1U} << pos); |
167 | 0 | } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItE5ResetEj Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjE5ResetEj Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImE5ResetEj |
168 | | /** Retrieve a bit at the given position. */ |
169 | | constexpr bool operator[](unsigned pos) const noexcept |
170 | 0 | { |
171 | 0 | Assume(pos < MAX_SIZE); |
172 | 0 | return (m_val >> pos) & 1U; |
173 | 0 | } Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetItEixEj Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetIjEixEj Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetImEixEj |
174 | | /** Compute the number of 1 bits in the bitset. */ |
175 | 0 | constexpr unsigned Count() const noexcept { return PopCount(m_val); } Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetItE5CountEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetIjE5CountEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetImE5CountEv |
176 | | /** Return the number of bits that this object holds. */ |
177 | 0 | static constexpr unsigned Size() noexcept { return MAX_SIZE; } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItE4SizeEv Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjE4SizeEv Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImE4SizeEv |
178 | | /** Check if all bits are 0. */ |
179 | 0 | constexpr bool None() const noexcept { return m_val == 0; } Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetItE4NoneEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetIjE4NoneEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetImE4NoneEv |
180 | | /** Check if any bits are 1. */ |
181 | 0 | constexpr bool Any() const noexcept { return !None(); } Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetItE3AnyEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetIjE3AnyEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetImE3AnyEv |
182 | | /** Return an object that iterates over all 1 bits (++ and * only allowed when != end()). */ |
183 | 0 | constexpr Iterator begin() const noexcept { return Iterator(m_val); } Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetItE5beginEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetIjE5beginEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetImE5beginEv |
184 | | /** Return a dummy object to compare Iterators with. */ |
185 | 0 | constexpr IteratorEnd end() const noexcept { return IteratorEnd(); } Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetItE3endEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetIjE3endEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetImE3endEv |
186 | | /** Find the first element (requires Any()). */ |
187 | | constexpr unsigned First() const noexcept |
188 | 0 | { |
189 | 0 | Assume(m_val != 0); |
190 | 0 | return std::countr_zero(m_val); |
191 | 0 | } Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetItE5FirstEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetIjE5FirstEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetImE5FirstEv |
192 | | /** Find the last element (requires Any()). */ |
193 | | constexpr unsigned Last() const noexcept |
194 | 0 | { |
195 | 0 | Assume(m_val != 0); |
196 | 0 | return std::bit_width(m_val) - 1; |
197 | 0 | } Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetItE4LastEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetIjE4LastEv Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetImE4LastEv |
198 | | /** Set this object's bits to be the binary AND between respective bits from this and a. */ |
199 | 0 | constexpr IntBitSet& operator|=(const IntBitSet& a) noexcept { m_val |= a.m_val; return *this; } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItEoRERKS1_ Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjEoRERKS1_ Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImEoRERKS1_ |
200 | | /** Set this object's bits to be the binary OR between respective bits from this and a. */ |
201 | 0 | constexpr IntBitSet& operator&=(const IntBitSet& a) noexcept { m_val &= a.m_val; return *this; } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItEaNERKS1_ Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjEaNERKS1_ Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImEaNERKS1_ |
202 | | /** Set this object's bits to be the binary AND NOT between respective bits from this and a. */ |
203 | 0 | constexpr IntBitSet& operator-=(const IntBitSet& a) noexcept { m_val &= ~a.m_val; return *this; } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItEmIERKS1_ Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjEmIERKS1_ Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImEmIERKS1_ |
204 | | /** Set this object's bits to be the binary XOR between respective bits from this as a. */ |
205 | 0 | constexpr IntBitSet& operator^=(const IntBitSet& a) noexcept { m_val ^= a.m_val; return *this; } Unexecuted instantiation: _ZN13bitset_detail9IntBitSetItEeOERKS1_ Unexecuted instantiation: _ZN13bitset_detail9IntBitSetIjEeOERKS1_ Unexecuted instantiation: _ZN13bitset_detail9IntBitSetImEeOERKS1_ |
206 | | /** Check if the intersection between two sets is non-empty. */ |
207 | 0 | constexpr bool Overlaps(const IntBitSet& a) const noexcept { return m_val & a.m_val; } Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetItE8OverlapsERKS1_ Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetIjE8OverlapsERKS1_ Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetImE8OverlapsERKS1_ |
208 | | /** Return an object with the binary AND between respective bits from a and b. */ |
209 | 0 | friend constexpr IntBitSet operator&(const IntBitSet& a, const IntBitSet& b) noexcept { return I(a.m_val & b.m_val); } Unexecuted instantiation: _ZN13bitset_detailanERKNS_9IntBitSetItEES3_ Unexecuted instantiation: _ZN13bitset_detailanERKNS_9IntBitSetIjEES3_ Unexecuted instantiation: _ZN13bitset_detailanERKNS_9IntBitSetImEES3_ |
210 | | /** Return an object with the binary OR between respective bits from a and b. */ |
211 | 0 | friend constexpr IntBitSet operator|(const IntBitSet& a, const IntBitSet& b) noexcept { return I(a.m_val | b.m_val); } Unexecuted instantiation: _ZN13bitset_detailorERKNS_9IntBitSetItEES3_ Unexecuted instantiation: _ZN13bitset_detailorERKNS_9IntBitSetIjEES3_ Unexecuted instantiation: _ZN13bitset_detailorERKNS_9IntBitSetImEES3_ |
212 | | /** Return an object with the binary AND NOT between respective bits from a and b. */ |
213 | 0 | friend constexpr IntBitSet operator-(const IntBitSet& a, const IntBitSet& b) noexcept { return I(a.m_val & ~b.m_val); } Unexecuted instantiation: _ZN13bitset_detailmiERKNS_9IntBitSetItEES3_ Unexecuted instantiation: _ZN13bitset_detailmiERKNS_9IntBitSetIjEES3_ Unexecuted instantiation: _ZN13bitset_detailmiERKNS_9IntBitSetImEES3_ |
214 | | /** Return an object with the binary XOR between respective bits from a and b. */ |
215 | 0 | friend constexpr IntBitSet operator^(const IntBitSet& a, const IntBitSet& b) noexcept { return I(a.m_val ^ b.m_val); } Unexecuted instantiation: _ZN13bitset_detaileoERKNS_9IntBitSetItEES3_ Unexecuted instantiation: _ZN13bitset_detaileoERKNS_9IntBitSetIjEES3_ Unexecuted instantiation: _ZN13bitset_detaileoERKNS_9IntBitSetImEES3_ |
216 | | /** Check if bitset a and bitset b are identical. */ |
217 | 0 | friend constexpr bool operator==(const IntBitSet& a, const IntBitSet& b) noexcept = default; Unexecuted instantiation: _ZN13bitset_detaileqERKNS_9IntBitSetItEES3_ Unexecuted instantiation: _ZN13bitset_detaileqERKNS_9IntBitSetIjEES3_ Unexecuted instantiation: _ZN13bitset_detaileqERKNS_9IntBitSetImEES3_ |
218 | | /** Check if bitset a is a superset of bitset b (= every 1 bit in b is also in a). */ |
219 | 0 | constexpr bool IsSupersetOf(const IntBitSet& a) const noexcept { return (a.m_val & ~m_val) == 0; } Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetItE12IsSupersetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetIjE12IsSupersetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetImE12IsSupersetOfERKS1_ |
220 | | /** Check if bitset a is a subset of bitset b (= every 1 bit in a is also in b). */ |
221 | 0 | constexpr bool IsSubsetOf(const IntBitSet& a) const noexcept { return (m_val & ~a.m_val) == 0; } Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetItE10IsSubsetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetIjE10IsSubsetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail9IntBitSetImE10IsSubsetOfERKS1_ |
222 | | /** Swap two bitsets. */ |
223 | 0 | friend constexpr void swap(IntBitSet& a, IntBitSet& b) noexcept { std::swap(a.m_val, b.m_val); } Unexecuted instantiation: _ZN13bitset_detail4swapERNS_9IntBitSetItEES2_ Unexecuted instantiation: _ZN13bitset_detail4swapERNS_9IntBitSetIjEES2_ Unexecuted instantiation: _ZN13bitset_detail4swapERNS_9IntBitSetImEES2_ |
224 | | }; |
225 | | |
226 | | /** A bitset implementation backed by N integers of type I. */ |
227 | | template<typename I, unsigned N> |
228 | | class MultiIntBitSet |
229 | | { |
230 | | // Only binary, unsigned, integer, types allowed. |
231 | | static_assert(std::is_integral_v<I> && std::is_unsigned_v<I> && std::numeric_limits<I>::radix == 2); |
232 | | // Cannot be empty. |
233 | | static_assert(N > 0); |
234 | | /** The number of bits per integer. */ |
235 | | static constexpr unsigned LIMB_BITS = std::numeric_limits<I>::digits; |
236 | | /** Number of elements this set type supports. */ |
237 | | static constexpr unsigned MAX_SIZE = LIMB_BITS * N; |
238 | | // No overflow allowed here. |
239 | | static_assert(MAX_SIZE / LIMB_BITS == N); |
240 | | /** Array whose member integers store the bits of the set. */ |
241 | | std::array<I, N> m_val; |
242 | | /** Dummy type to return using end(). Only used for comparing with Iterator. */ |
243 | | class IteratorEnd |
244 | | { |
245 | | friend class MultiIntBitSet; |
246 | | constexpr IteratorEnd() = default; |
247 | | public: |
248 | | constexpr IteratorEnd(const IteratorEnd&) = default; |
249 | | }; |
250 | | /** Iterator type returned by begin(), which efficiently iterates all 1 positions. */ |
251 | | class Iterator |
252 | | { |
253 | | friend class MultiIntBitSet; |
254 | | const std::array<I, N>* m_ptr; /**< Pointer to array to fetch bits from. */ |
255 | | I m_val; /**< The remaining bits of (*m_ptr)[m_idx]. */ |
256 | | unsigned m_pos; /**< The last reported position. */ |
257 | | unsigned m_idx; /**< The index in *m_ptr currently being iterated over. */ |
258 | 0 | constexpr Iterator(const std::array<I, N>& ref) noexcept : m_ptr(&ref), m_idx(0) |
259 | 0 | { |
260 | 0 | do { |
261 | 0 | m_val = (*m_ptr)[m_idx]; |
262 | 0 | if (m_val) { |
263 | 0 | m_pos = std::countr_zero(m_val) + m_idx * LIMB_BITS; |
264 | 0 | break; |
265 | 0 | } |
266 | 0 | ++m_idx; |
267 | 0 | } while(m_idx < N); |
268 | 0 | } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EE8IteratorC2ERKSt5arrayItLm1EE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EE8IteratorC2ERKSt5arrayItLm2EE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EE8IteratorC2ERKSt5arrayItLm3EE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EE8IteratorC2ERKSt5arrayImLm1EE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EE8IteratorC2ERKSt5arrayIjLm2EE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EE8IteratorC2ERKSt5arrayItLm4EE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EE8IteratorC2ERKSt5arrayIjLm3EE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EE8IteratorC2ERKSt5arrayImLm2EE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EE8IteratorC2ERKSt5arrayIjLm4EE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EE8IteratorC2ERKSt5arrayImLm3EE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EE8IteratorC2ERKSt5arrayImLm4EE |
269 | | |
270 | | public: |
271 | | /** Do not allow external code to construct an Iterator. */ |
272 | | Iterator() = delete; |
273 | | // Copying is allowed. |
274 | | constexpr Iterator(const Iterator&) noexcept = default; |
275 | | constexpr Iterator& operator=(const Iterator&) noexcept = default; |
276 | | /** Test whether we are done (can only compare with IteratorEnd). */ |
277 | | friend constexpr bool operator==(const Iterator& a, const IteratorEnd&) noexcept |
278 | 0 | { |
279 | 0 | return a.m_idx == N; |
280 | 0 | } Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetItLj1EE8IteratorERKNS1_11IteratorEndE Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetItLj2EE8IteratorERKNS1_11IteratorEndE Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetItLj3EE8IteratorERKNS1_11IteratorEndE Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetImLj1EE8IteratorERKNS1_11IteratorEndE Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetIjLj2EE8IteratorERKNS1_11IteratorEndE Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetItLj4EE8IteratorERKNS1_11IteratorEndE Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetIjLj3EE8IteratorERKNS1_11IteratorEndE Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetImLj2EE8IteratorERKNS1_11IteratorEndE Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetIjLj4EE8IteratorERKNS1_11IteratorEndE Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetImLj3EE8IteratorERKNS1_11IteratorEndE Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetImLj4EE8IteratorERKNS1_11IteratorEndE |
281 | | /** Progress to the next 1 bit (only if != IteratorEnd). */ |
282 | | constexpr Iterator& operator++() noexcept |
283 | 0 | { |
284 | 0 | Assume(m_idx < N); |
285 | 0 | m_val &= m_val - I{1U}; |
286 | 0 | if (m_val == 0) { |
287 | 0 | while (true) { |
288 | 0 | ++m_idx; |
289 | 0 | if (m_idx == N) break; |
290 | 0 | m_val = (*m_ptr)[m_idx]; |
291 | 0 | if (m_val) { |
292 | 0 | m_pos = std::countr_zero(m_val) + m_idx * LIMB_BITS; |
293 | 0 | break; |
294 | 0 | } |
295 | 0 | } |
296 | 0 | } else { |
297 | 0 | m_pos = std::countr_zero(m_val) + m_idx * LIMB_BITS; |
298 | 0 | } |
299 | 0 | return *this; |
300 | 0 | } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EE8IteratorppEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EE8IteratorppEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EE8IteratorppEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EE8IteratorppEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EE8IteratorppEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EE8IteratorppEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EE8IteratorppEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EE8IteratorppEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EE8IteratorppEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EE8IteratorppEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EE8IteratorppEv |
301 | | /** Get the current bit position (only if != IteratorEnd). */ |
302 | | constexpr unsigned operator*() const noexcept |
303 | 0 | { |
304 | 0 | Assume(m_idx < N); |
305 | 0 | return m_pos; |
306 | 0 | } Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj1EE8IteratordeEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj2EE8IteratordeEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj3EE8IteratordeEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj1EE8IteratordeEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj2EE8IteratordeEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj4EE8IteratordeEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj3EE8IteratordeEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj2EE8IteratordeEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj4EE8IteratordeEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj3EE8IteratordeEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj4EE8IteratordeEv |
307 | | }; |
308 | | |
309 | | public: |
310 | | /** Construct an all-zero bitset. */ |
311 | 0 | constexpr MultiIntBitSet() noexcept : m_val{} {} Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EEC2Ev Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EEC2Ev Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EEC2Ev Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EEC2Ev Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EEC2Ev Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EEC2Ev Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EEC2Ev Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EEC2Ev Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EEC2Ev Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EEC2Ev Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EEC2Ev |
312 | | /** Copy construct a bitset. */ |
313 | | constexpr MultiIntBitSet(const MultiIntBitSet&) noexcept = default; |
314 | | /** Copy assign a bitset. */ |
315 | | constexpr MultiIntBitSet& operator=(const MultiIntBitSet&) noexcept = default; |
316 | | /** Set a bit to 1. */ |
317 | | void constexpr Set(unsigned pos) noexcept |
318 | 0 | { |
319 | 0 | Assume(pos < MAX_SIZE); |
320 | 0 | m_val[pos / LIMB_BITS] |= I{1U} << (pos % LIMB_BITS); |
321 | 0 | } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EE3SetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EE3SetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EE3SetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EE3SetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EE3SetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EE3SetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EE3SetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EE3SetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EE3SetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EE3SetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EE3SetEj |
322 | | /** Set a bit to the specified value. */ |
323 | | void constexpr Set(unsigned pos, bool val) noexcept |
324 | 0 | { |
325 | 0 | Assume(pos < MAX_SIZE); |
326 | 0 | m_val[pos / LIMB_BITS] = (m_val[pos / LIMB_BITS] & ~I(I{1U} << (pos % LIMB_BITS))) | |
327 | 0 | (I{val} << (pos % LIMB_BITS)); |
328 | 0 | } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EE3SetEjb Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EE3SetEjb Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EE3SetEjb Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EE3SetEjb Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EE3SetEjb Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EE3SetEjb Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EE3SetEjb Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EE3SetEjb Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EE3SetEjb Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EE3SetEjb Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EE3SetEjb |
329 | | /** Construct a bitset from a list of values. */ |
330 | 0 | constexpr MultiIntBitSet(std::initializer_list<unsigned> ilist) noexcept : m_val{} |
331 | 0 | { |
332 | 0 | for (auto pos : ilist) Set(pos); |
333 | 0 | } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EEC2ESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EEC2ESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EEC2ESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EEC2ESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EEC2ESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EEC2ESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EEC2ESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EEC2ESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EEC2ESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EEC2ESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EEC2ESt16initializer_listIjE |
334 | | /** Set a bitset to a list of values. */ |
335 | | constexpr MultiIntBitSet& operator=(std::initializer_list<unsigned> ilist) noexcept |
336 | 0 | { |
337 | 0 | m_val.fill(0); |
338 | 0 | for (auto pos : ilist) Set(pos); |
339 | 0 | return *this; |
340 | 0 | } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EEaSESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EEaSESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EEaSESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EEaSESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EEaSESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EEaSESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EEaSESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EEaSESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EEaSESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EEaSESt16initializer_listIjE Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EEaSESt16initializer_listIjE |
341 | | /** Set a bit to 0. */ |
342 | | void constexpr Reset(unsigned pos) noexcept |
343 | 0 | { |
344 | 0 | Assume(pos < MAX_SIZE); |
345 | 0 | m_val[pos / LIMB_BITS] &= ~I(I{1U} << (pos % LIMB_BITS)); |
346 | 0 | } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EE5ResetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EE5ResetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EE5ResetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EE5ResetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EE5ResetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EE5ResetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EE5ResetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EE5ResetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EE5ResetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EE5ResetEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EE5ResetEj |
347 | | /** Retrieve a bit at the given position. */ |
348 | | bool constexpr operator[](unsigned pos) const noexcept |
349 | 0 | { |
350 | 0 | Assume(pos < MAX_SIZE); |
351 | 0 | return (m_val[pos / LIMB_BITS] >> (pos % LIMB_BITS)) & 1U; |
352 | 0 | } Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj1EEixEj Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj2EEixEj Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj3EEixEj Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj1EEixEj Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj2EEixEj Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj4EEixEj Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj3EEixEj Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj2EEixEj Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj4EEixEj Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj3EEixEj Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj4EEixEj |
353 | | /** Construct a bitset with the singleton pos. */ |
354 | | static constexpr MultiIntBitSet Singleton(unsigned pos) noexcept |
355 | 0 | { |
356 | 0 | Assume(pos < MAX_SIZE); |
357 | 0 | MultiIntBitSet ret; |
358 | 0 | ret.m_val[pos / LIMB_BITS] = I{1U} << (pos % LIMB_BITS); |
359 | 0 | return ret; |
360 | 0 | } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EE9SingletonEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EE9SingletonEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EE9SingletonEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EE9SingletonEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EE9SingletonEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EE9SingletonEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EE9SingletonEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EE9SingletonEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EE9SingletonEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EE9SingletonEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EE9SingletonEj |
361 | | /** Construct a bitset with bits 0..count-1 (inclusive) set to 1. */ |
362 | | static constexpr MultiIntBitSet Fill(unsigned count) noexcept |
363 | 0 | { |
364 | 0 | Assume(count <= MAX_SIZE); |
365 | 0 | MultiIntBitSet ret; |
366 | 0 | if (count) { |
367 | 0 | unsigned i = 0; |
368 | 0 | while (count > LIMB_BITS) { |
369 | 0 | ret.m_val[i++] = ~I{0}; |
370 | 0 | count -= LIMB_BITS; |
371 | 0 | } |
372 | 0 | ret.m_val[i] = I(~I{0}) >> (LIMB_BITS - count); |
373 | 0 | } |
374 | 0 | return ret; |
375 | 0 | } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EE4FillEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EE4FillEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EE4FillEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EE4FillEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EE4FillEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EE4FillEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EE4FillEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EE4FillEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EE4FillEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EE4FillEj Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EE4FillEj |
376 | | /** Return the number of bits that this object holds. */ |
377 | 0 | static constexpr unsigned Size() noexcept { return MAX_SIZE; } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EE4SizeEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EE4SizeEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EE4SizeEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EE4SizeEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EE4SizeEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EE4SizeEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EE4SizeEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EE4SizeEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EE4SizeEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EE4SizeEv Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EE4SizeEv |
378 | | /** Compute the number of 1 bits in the bitset. */ |
379 | | unsigned constexpr Count() const noexcept |
380 | 0 | { |
381 | 0 | unsigned ret{0}; |
382 | 0 | for (I v : m_val) ret += PopCount(v); |
383 | 0 | return ret; |
384 | 0 | } Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj1EE5CountEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj2EE5CountEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj3EE5CountEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj1EE5CountEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj2EE5CountEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj4EE5CountEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj3EE5CountEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj2EE5CountEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj4EE5CountEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj3EE5CountEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj4EE5CountEv |
385 | | /** Check if all bits are 0. */ |
386 | | bool constexpr None() const noexcept |
387 | 0 | { |
388 | 0 | for (auto v : m_val) { |
389 | 0 | if (v != 0) return false; |
390 | 0 | } |
391 | 0 | return true; |
392 | 0 | } Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj1EE4NoneEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj2EE4NoneEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj3EE4NoneEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj1EE4NoneEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj2EE4NoneEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj4EE4NoneEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj3EE4NoneEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj2EE4NoneEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj4EE4NoneEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj3EE4NoneEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj4EE4NoneEv |
393 | | /** Check if any bits are 1. */ |
394 | 0 | bool constexpr Any() const noexcept { return !None(); } Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj1EE3AnyEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj2EE3AnyEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj3EE3AnyEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj1EE3AnyEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj2EE3AnyEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj4EE3AnyEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj3EE3AnyEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj2EE3AnyEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj4EE3AnyEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj3EE3AnyEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj4EE3AnyEv |
395 | | /** Return an object that iterates over all 1 bits (++ and * only allowed when != end()). */ |
396 | 0 | Iterator constexpr begin() const noexcept { return Iterator(m_val); } Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj1EE5beginEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj2EE5beginEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj3EE5beginEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj1EE5beginEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj2EE5beginEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj4EE5beginEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj3EE5beginEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj2EE5beginEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj4EE5beginEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj3EE5beginEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj4EE5beginEv |
397 | | /** Return a dummy object to compare Iterators with. */ |
398 | 0 | IteratorEnd constexpr end() const noexcept { return IteratorEnd(); } Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj1EE3endEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj2EE3endEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj3EE3endEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj1EE3endEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj2EE3endEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj4EE3endEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj3EE3endEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj2EE3endEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj4EE3endEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj3EE3endEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj4EE3endEv |
399 | | /** Find the first element (requires Any()). */ |
400 | | unsigned constexpr First() const noexcept |
401 | 0 | { |
402 | 0 | unsigned p = 0; |
403 | 0 | while (m_val[p] == 0) { |
404 | 0 | ++p; |
405 | 0 | Assume(p < N); |
406 | 0 | } |
407 | 0 | return std::countr_zero(m_val[p]) + p * LIMB_BITS; |
408 | 0 | } Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj1EE5FirstEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj2EE5FirstEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj3EE5FirstEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj1EE5FirstEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj2EE5FirstEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj4EE5FirstEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj3EE5FirstEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj2EE5FirstEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj4EE5FirstEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj3EE5FirstEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj4EE5FirstEv |
409 | | /** Find the last element (requires Any()). */ |
410 | | unsigned constexpr Last() const noexcept |
411 | 0 | { |
412 | 0 | unsigned p = N - 1; |
413 | 0 | while (m_val[p] == 0) { |
414 | 0 | Assume(p > 0); |
415 | 0 | --p; |
416 | 0 | } |
417 | 0 | return std::bit_width(m_val[p]) - 1 + p * LIMB_BITS; |
418 | 0 | } Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj1EE4LastEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj2EE4LastEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj3EE4LastEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj1EE4LastEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj2EE4LastEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj4EE4LastEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj3EE4LastEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj2EE4LastEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj4EE4LastEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj3EE4LastEv Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj4EE4LastEv |
419 | | /** Set this object's bits to be the binary OR between respective bits from this and a. */ |
420 | | constexpr MultiIntBitSet& operator|=(const MultiIntBitSet& a) noexcept |
421 | 0 | { |
422 | 0 | for (unsigned i = 0; i < N; ++i) { |
423 | 0 | m_val[i] |= a.m_val[i]; |
424 | 0 | } |
425 | 0 | return *this; |
426 | 0 | } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EEoRERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EEoRERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EEoRERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EEoRERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EEoRERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EEoRERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EEoRERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EEoRERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EEoRERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EEoRERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EEoRERKS1_ |
427 | | /** Set this object's bits to be the binary AND between respective bits from this and a. */ |
428 | | constexpr MultiIntBitSet& operator&=(const MultiIntBitSet& a) noexcept |
429 | 0 | { |
430 | 0 | for (unsigned i = 0; i < N; ++i) { |
431 | 0 | m_val[i] &= a.m_val[i]; |
432 | 0 | } |
433 | 0 | return *this; |
434 | 0 | } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EEaNERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EEaNERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EEaNERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EEaNERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EEaNERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EEaNERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EEaNERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EEaNERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EEaNERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EEaNERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EEaNERKS1_ |
435 | | /** Set this object's bits to be the binary AND NOT between respective bits from this and a. */ |
436 | | constexpr MultiIntBitSet& operator-=(const MultiIntBitSet& a) noexcept |
437 | 0 | { |
438 | 0 | for (unsigned i = 0; i < N; ++i) { |
439 | 0 | m_val[i] &= ~a.m_val[i]; |
440 | 0 | } |
441 | 0 | return *this; |
442 | 0 | } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EEmIERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EEmIERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EEmIERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EEmIERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EEmIERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EEmIERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EEmIERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EEmIERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EEmIERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EEmIERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EEmIERKS1_ |
443 | | /** Set this object's bits to be the binary XOR between respective bits from this and a. */ |
444 | | constexpr MultiIntBitSet& operator^=(const MultiIntBitSet& a) noexcept |
445 | 0 | { |
446 | 0 | for (unsigned i = 0; i < N; ++i) { |
447 | 0 | m_val[i] ^= a.m_val[i]; |
448 | 0 | } |
449 | 0 | return *this; |
450 | 0 | } Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj1EEeOERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj2EEeOERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj3EEeOERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj1EEeOERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj2EEeOERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetItLj4EEeOERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj3EEeOERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj2EEeOERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetIjLj4EEeOERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj3EEeOERKS1_ Unexecuted instantiation: _ZN13bitset_detail14MultiIntBitSetImLj4EEeOERKS1_ |
451 | | /** Check whether the intersection between two sets is non-empty. */ |
452 | | constexpr bool Overlaps(const MultiIntBitSet& a) const noexcept |
453 | 0 | { |
454 | 0 | for (unsigned i = 0; i < N; ++i) { |
455 | 0 | if (m_val[i] & a.m_val[i]) return true; |
456 | 0 | } |
457 | 0 | return false; |
458 | 0 | } Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj1EE8OverlapsERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj2EE8OverlapsERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj3EE8OverlapsERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj1EE8OverlapsERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj2EE8OverlapsERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj4EE8OverlapsERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj3EE8OverlapsERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj2EE8OverlapsERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj4EE8OverlapsERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj3EE8OverlapsERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj4EE8OverlapsERKS1_ |
459 | | /** Return an object with the binary AND between respective bits from a and b. */ |
460 | | friend constexpr MultiIntBitSet operator&(const MultiIntBitSet& a, const MultiIntBitSet& b) noexcept |
461 | 0 | { |
462 | 0 | MultiIntBitSet r; |
463 | 0 | for (unsigned i = 0; i < N; ++i) { |
464 | 0 | r.m_val[i] = a.m_val[i] & b.m_val[i]; |
465 | 0 | } |
466 | 0 | return r; |
467 | 0 | } Unexecuted instantiation: _ZN13bitset_detailanERKNS_14MultiIntBitSetItLj1EEES3_ Unexecuted instantiation: _ZN13bitset_detailanERKNS_14MultiIntBitSetItLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detailanERKNS_14MultiIntBitSetItLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detailanERKNS_14MultiIntBitSetImLj1EEES3_ Unexecuted instantiation: _ZN13bitset_detailanERKNS_14MultiIntBitSetIjLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detailanERKNS_14MultiIntBitSetItLj4EEES3_ Unexecuted instantiation: _ZN13bitset_detailanERKNS_14MultiIntBitSetIjLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detailanERKNS_14MultiIntBitSetImLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detailanERKNS_14MultiIntBitSetIjLj4EEES3_ Unexecuted instantiation: _ZN13bitset_detailanERKNS_14MultiIntBitSetImLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detailanERKNS_14MultiIntBitSetImLj4EEES3_ |
468 | | /** Return an object with the binary OR between respective bits from a and b. */ |
469 | | friend constexpr MultiIntBitSet operator|(const MultiIntBitSet& a, const MultiIntBitSet& b) noexcept |
470 | 0 | { |
471 | 0 | MultiIntBitSet r; |
472 | 0 | for (unsigned i = 0; i < N; ++i) { |
473 | 0 | r.m_val[i] = a.m_val[i] | b.m_val[i]; |
474 | 0 | } |
475 | 0 | return r; |
476 | 0 | } Unexecuted instantiation: _ZN13bitset_detailorERKNS_14MultiIntBitSetItLj1EEES3_ Unexecuted instantiation: _ZN13bitset_detailorERKNS_14MultiIntBitSetItLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detailorERKNS_14MultiIntBitSetItLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detailorERKNS_14MultiIntBitSetImLj1EEES3_ Unexecuted instantiation: _ZN13bitset_detailorERKNS_14MultiIntBitSetIjLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detailorERKNS_14MultiIntBitSetItLj4EEES3_ Unexecuted instantiation: _ZN13bitset_detailorERKNS_14MultiIntBitSetIjLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detailorERKNS_14MultiIntBitSetImLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detailorERKNS_14MultiIntBitSetIjLj4EEES3_ Unexecuted instantiation: _ZN13bitset_detailorERKNS_14MultiIntBitSetImLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detailorERKNS_14MultiIntBitSetImLj4EEES3_ |
477 | | /** Return an object with the binary AND NOT between respective bits from a and b. */ |
478 | | friend constexpr MultiIntBitSet operator-(const MultiIntBitSet& a, const MultiIntBitSet& b) noexcept |
479 | 0 | { |
480 | 0 | MultiIntBitSet r; |
481 | 0 | for (unsigned i = 0; i < N; ++i) { |
482 | 0 | r.m_val[i] = a.m_val[i] & ~b.m_val[i]; |
483 | 0 | } |
484 | 0 | return r; |
485 | 0 | } Unexecuted instantiation: _ZN13bitset_detailmiERKNS_14MultiIntBitSetItLj1EEES3_ Unexecuted instantiation: _ZN13bitset_detailmiERKNS_14MultiIntBitSetItLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detailmiERKNS_14MultiIntBitSetItLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detailmiERKNS_14MultiIntBitSetImLj1EEES3_ Unexecuted instantiation: _ZN13bitset_detailmiERKNS_14MultiIntBitSetIjLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detailmiERKNS_14MultiIntBitSetItLj4EEES3_ Unexecuted instantiation: _ZN13bitset_detailmiERKNS_14MultiIntBitSetIjLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detailmiERKNS_14MultiIntBitSetImLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detailmiERKNS_14MultiIntBitSetIjLj4EEES3_ Unexecuted instantiation: _ZN13bitset_detailmiERKNS_14MultiIntBitSetImLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detailmiERKNS_14MultiIntBitSetImLj4EEES3_ |
486 | | /** Return an object with the binary XOR between respective bits from a and b. */ |
487 | | friend constexpr MultiIntBitSet operator^(const MultiIntBitSet& a, const MultiIntBitSet& b) noexcept |
488 | 0 | { |
489 | 0 | MultiIntBitSet r; |
490 | 0 | for (unsigned i = 0; i < N; ++i) { |
491 | 0 | r.m_val[i] = a.m_val[i] ^ b.m_val[i]; |
492 | 0 | } |
493 | 0 | return r; |
494 | 0 | } Unexecuted instantiation: _ZN13bitset_detaileoERKNS_14MultiIntBitSetItLj1EEES3_ Unexecuted instantiation: _ZN13bitset_detaileoERKNS_14MultiIntBitSetItLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detaileoERKNS_14MultiIntBitSetItLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detaileoERKNS_14MultiIntBitSetImLj1EEES3_ Unexecuted instantiation: _ZN13bitset_detaileoERKNS_14MultiIntBitSetIjLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detaileoERKNS_14MultiIntBitSetItLj4EEES3_ Unexecuted instantiation: _ZN13bitset_detaileoERKNS_14MultiIntBitSetIjLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detaileoERKNS_14MultiIntBitSetImLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detaileoERKNS_14MultiIntBitSetIjLj4EEES3_ Unexecuted instantiation: _ZN13bitset_detaileoERKNS_14MultiIntBitSetImLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detaileoERKNS_14MultiIntBitSetImLj4EEES3_ |
495 | | /** Check if bitset a is a superset of bitset b (= every 1 bit in b is also in a). */ |
496 | | constexpr bool IsSupersetOf(const MultiIntBitSet& a) const noexcept |
497 | 0 | { |
498 | 0 | for (unsigned i = 0; i < N; ++i) { |
499 | 0 | if (a.m_val[i] & ~m_val[i]) return false; |
500 | 0 | } |
501 | 0 | return true; |
502 | 0 | } Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj1EE12IsSupersetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj2EE12IsSupersetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj3EE12IsSupersetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj1EE12IsSupersetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj2EE12IsSupersetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj4EE12IsSupersetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj3EE12IsSupersetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj2EE12IsSupersetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj4EE12IsSupersetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj3EE12IsSupersetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj4EE12IsSupersetOfERKS1_ |
503 | | /** Check if bitset a is a subset of bitset b (= every 1 bit in a is also in b). */ |
504 | | constexpr bool IsSubsetOf(const MultiIntBitSet& a) const noexcept |
505 | 0 | { |
506 | 0 | for (unsigned i = 0; i < N; ++i) { |
507 | 0 | if (m_val[i] & ~a.m_val[i]) return false; |
508 | 0 | } |
509 | 0 | return true; |
510 | 0 | } Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj1EE10IsSubsetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj2EE10IsSubsetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj3EE10IsSubsetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj1EE10IsSubsetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj2EE10IsSubsetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetItLj4EE10IsSubsetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj3EE10IsSubsetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj2EE10IsSubsetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetIjLj4EE10IsSubsetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj3EE10IsSubsetOfERKS1_ Unexecuted instantiation: _ZNK13bitset_detail14MultiIntBitSetImLj4EE10IsSubsetOfERKS1_ |
511 | | /** Check if bitset a and bitset b are identical. */ |
512 | 0 | friend constexpr bool operator==(const MultiIntBitSet& a, const MultiIntBitSet& b) noexcept = default; Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetItLj1EEES3_ Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetItLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetItLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetImLj1EEES3_ Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetIjLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetItLj4EEES3_ Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetIjLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetImLj2EEES3_ Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetIjLj4EEES3_ Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetImLj3EEES3_ Unexecuted instantiation: _ZN13bitset_detaileqERKNS_14MultiIntBitSetImLj4EEES3_ |
513 | | /** Swap two bitsets. */ |
514 | 0 | friend constexpr void swap(MultiIntBitSet& a, MultiIntBitSet& b) noexcept { std::swap(a.m_val, b.m_val); } Unexecuted instantiation: _ZN13bitset_detail4swapERNS_14MultiIntBitSetItLj1EEES2_ Unexecuted instantiation: _ZN13bitset_detail4swapERNS_14MultiIntBitSetItLj2EEES2_ Unexecuted instantiation: _ZN13bitset_detail4swapERNS_14MultiIntBitSetItLj3EEES2_ Unexecuted instantiation: _ZN13bitset_detail4swapERNS_14MultiIntBitSetImLj1EEES2_ Unexecuted instantiation: _ZN13bitset_detail4swapERNS_14MultiIntBitSetIjLj2EEES2_ Unexecuted instantiation: _ZN13bitset_detail4swapERNS_14MultiIntBitSetItLj4EEES2_ Unexecuted instantiation: _ZN13bitset_detail4swapERNS_14MultiIntBitSetIjLj3EEES2_ Unexecuted instantiation: _ZN13bitset_detail4swapERNS_14MultiIntBitSetImLj2EEES2_ Unexecuted instantiation: _ZN13bitset_detail4swapERNS_14MultiIntBitSetIjLj4EEES2_ Unexecuted instantiation: _ZN13bitset_detail4swapERNS_14MultiIntBitSetImLj3EEES2_ Unexecuted instantiation: _ZN13bitset_detail4swapERNS_14MultiIntBitSetImLj4EEES2_ |
515 | | }; |
516 | | |
517 | | } // namespace bitset_detail |
518 | | |
519 | | // BitSet dispatches to IntBitSet or MultiIntBitSet as appropriate for the requested minimum number |
520 | | // of bits. Use IntBitSet up to 32-bit, or up to 64-bit on 64-bit platforms; above that, use a |
521 | | // MultiIntBitSet of size_t. |
522 | | template<unsigned BITS> |
523 | | using BitSet = std::conditional_t<(BITS <= 32), bitset_detail::IntBitSet<uint32_t>, |
524 | | std::conditional_t<(BITS <= std::numeric_limits<size_t>::digits), bitset_detail::IntBitSet<size_t>, |
525 | | bitset_detail::MultiIntBitSet<size_t, (BITS + std::numeric_limits<size_t>::digits - 1) / std::numeric_limits<size_t>::digits>>>; |
526 | | |
527 | | #endif // BITCOIN_UTIL_BITSET_H |