MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMesh/MRBitSet.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include "MRId.h"
5#include "MRphmap.h"
6#include "MRVector.h"
7#include "MRPch/MRBindingMacros.h"
8#define BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
9#pragma warning(push)
10#pragma warning(disable: 4643) //Forward declaring in namespace std is not permitted by the C++ Standard.
11#include <boost/dynamic_bitset.hpp>
12#pragma warning(pop)
13#include <iterator>
14#include <functional>
15
16namespace MR
17{
18
27class BitSet : public boost::dynamic_bitset<std::uint64_t>
28{
29public:
30 using base = boost::dynamic_bitset<std::uint64_t>;
31 using base::base;
32 using IndexType = size_t;
33
35 explicit BitSet( size_t numBits, bool fillValue ) { resize( numBits, fillValue ); }
36
38 explicit BitSet( size_t, unsigned long ) = delete;
39 template<class T, std::enable_if_t<std::is_arithmetic<T>::value, std::nullptr_t> = nullptr>
40 explicit BitSet( T, T ) = delete;
41
42 // all bits after size() we silently consider as not-set
43 [[nodiscard]] bool test( IndexType n ) const { return n < size() && base::test( n ); }
44 [[nodiscard]] bool test_set( IndexType n, bool val = true ) { return ( val || n < size() ) ? base::test_set( n, val ) : false; }
45
46 BitSet & set( IndexType n, size_type len, bool val ) { base::set( n, len, val ); return * this; }
47 BitSet & set( IndexType n, bool val ) { base::set( n, val ); return * this; } // Not using a default argument for `val` to get better C bindings.
48 BitSet & set( IndexType n ) { base::set( n ); return * this; }
49 BitSet & set() { base::set(); return * this; }
50 BitSet & reset( IndexType n, size_type len ) { if ( n < size() ) base::reset( n, len ); return * this; }
51 BitSet & reset( IndexType n ) { if ( n < size() ) base::reset( n ); return * this; }
52 BitSet & reset() { base::reset(); return * this; }
53 BitSet & flip( IndexType n, size_type len ) { base::flip( n, len ); return * this; }
54 BitSet & flip( IndexType n ) { base::flip( n ); return * this; }
55 BitSet & flip() { base::flip(); return * this; }
56
58 const auto & bits() const { return m_bits; }
59
63
66 MRMESH_API BitSet & subtract( const BitSet & b, int bShiftInBlocks );
67
69 [[nodiscard]] MRMESH_API IndexType find_last() const;
70
72 [[nodiscard]] MRMESH_API size_t nthSetBit( size_t n ) const;
73
75 [[nodiscard]] MRMESH_API bool is_subset_of( const BitSet& a ) const;
76
78 bool is_proper_subset_of( const BitSet& a ) const = delete; // base implementation does not support bitsets of different sizes
79
81 void resizeWithReserve( size_t newSize )
82 {
83 auto reserved = capacity();
84 if ( reserved > 0 && newSize > reserved )
85 {
86 while ( newSize > reserved )
87 reserved <<= 1;
88 reserve( reserved );
89 }
90 resize( newSize );
91 }
92
94 void autoResizeSet( size_t pos, size_type len, bool val = true )
95 {
96 if ( pos + len > size() )
97 resizeWithReserve( pos + len );
98 set( pos, len, val );
99 }
100 void autoResizeSet( size_t pos, bool val = true ) { autoResizeSet( pos, 1, val ); }
101
103 [[nodiscard]] bool autoResizeTestSet( size_t pos, bool val = true )
104 {
105 bool const b = test( pos );
106 if ( b != val )
107 autoResizeSet( pos, val );
108 return b;
109 }
110
112 [[nodiscard]] size_t heapBytes() const { return capacity() / 8; }
113
115 [[nodiscard]] IndexType backId() const { assert( !empty() ); return IndexType{ size() - 1 }; }
116
118 [[nodiscard]] static IndexType beginId() { return IndexType{ 0 }; }
119 [[nodiscard]] IndexType endId() const { return IndexType{ size() }; }
120
121 // Normally those are inherited from `boost::dynamic_bitset`, but MRBind currently chokes on it, so we provide those manually.
122 #if defined(MR_PARSING_FOR_ANY_BINDINGS) || defined(MR_COMPILING_ANY_BINDINGS)
123 std::size_t size() const { return dynamic_bitset::size(); }
124 std::size_t count() const { return dynamic_bitset::count(); }
125 void resize( std::size_t num_bits, bool value = false ) { dynamic_bitset::resize( num_bits, value ); }
126 void clear() { dynamic_bitset::clear(); }
127 void push_back( bool bit ) { dynamic_bitset::push_back( bit ); }
128 void pop_back() { dynamic_bitset::pop_back(); }
129 #endif
130
131private:
132 using base::m_highest_block;
133 using base::m_bits;
134 using base::m_num_bits;
135};
136
139template <typename I>
140class TypedBitSet : public BitSet
141{
142 using base = BitSet;
143public:
144 using base::base;
145 using IndexType = I;
146
148 explicit TypedBitSet( const BitSet & src ) : BitSet( src ) {}
149
151 explicit TypedBitSet( BitSet && src ) : BitSet( std::move( src ) ) {}
152
153 TypedBitSet & set( IndexType n, size_type len, bool val ) { base::set( n, len, val ); return * this; }
154 TypedBitSet & set( IndexType n, bool val ) { base::set( n, val ); return * this; } // Not using a default argument for `val` to get better C bindings.
155 TypedBitSet & set( IndexType n ) { base::set( n ); return * this; }
156 TypedBitSet & set() { base::set(); return * this; }
157 TypedBitSet & reset( IndexType n, size_type len ) { base::reset( n, len ); return * this; }
158 TypedBitSet & reset( IndexType n ) { base::reset( n ); return * this; }
159 TypedBitSet & reset() { base::reset(); return * this; }
160 TypedBitSet & flip( IndexType n, size_type len ) { base::flip( n, len ); return * this; }
161 TypedBitSet & flip( IndexType n ) { base::flip( n ); return * this; }
162 TypedBitSet & flip() { base::flip(); return * this; }
163 [[nodiscard]] bool test( IndexType n ) const { return base::test( n ); }
164 [[nodiscard]] bool test_set( IndexType n, bool val = true ) { return base::test_set( n, val ); }
165
166 // Disable for python bindings, because MRBind chokes on `boost::dynamic_bitset::reference`.
167 [[nodiscard]] MR_BIND_IGNORE reference operator[]( IndexType pos ) { return base::operator[]( pos ); }
168 [[nodiscard]] bool operator[]( IndexType pos ) const { return base::operator[]( pos ); }
169
170 [[nodiscard]] IndexType find_first() const { return IndexType( base::find_first() ); }
171 [[nodiscard]] IndexType find_next( IndexType pos ) const { return IndexType( base::find_next( pos ) ); }
172 [[nodiscard]] IndexType find_last() const { return IndexType( base::find_last() ); }
174 [[nodiscard]] IndexType nthSetBit( size_t n ) const { return IndexType( base::nthSetBit( n ) ); }
175
176 TypedBitSet & operator &= ( const TypedBitSet & b ) { base::operator &= ( b ); return * this; }
177 TypedBitSet & operator |= ( const TypedBitSet & b ) { base::operator |= ( b ); return * this; }
178 TypedBitSet & operator ^= ( const TypedBitSet & b ) { base::operator ^= ( b ); return * this; }
179 TypedBitSet & operator -= ( const TypedBitSet & b ) { base::operator -= ( b ); return * this; }
180
181 [[nodiscard]] friend TypedBitSet operator & ( const TypedBitSet & a, const TypedBitSet & b ) { auto res{ a }; res &= b; return res; }
182 [[nodiscard]] friend TypedBitSet operator | ( const TypedBitSet & a, const TypedBitSet & b ) { auto res{ a }; res |= b; return res; }
183 [[nodiscard]] friend TypedBitSet operator ^ ( const TypedBitSet & a, const TypedBitSet & b ) { auto res{ a }; res ^= b; return res; }
184 [[nodiscard]] friend TypedBitSet operator - ( const TypedBitSet & a, const TypedBitSet & b ) { auto res{ a }; res -= b; return res; }
185
187 TypedBitSet & subtract( const TypedBitSet & b, int bShiftInBlocks ) { base::subtract( b, bShiftInBlocks ); return * this; }
188
190 [[nodiscard]] bool is_subset_of( const TypedBitSet& a ) const { return base::is_subset_of( a ); }
191
193 [[nodiscard]] bool intersects( const TypedBitSet & a ) const { return base::intersects( a ); }
194
195 void autoResizeSet( IndexType pos, size_type len, bool val = true ) { base::autoResizeSet( pos, len, val ); }
196 void autoResizeSet( IndexType pos, bool val = true ) { base::autoResizeSet( pos, val ); }
197 [[nodiscard]] bool autoResizeTestSet( IndexType pos, bool val = true ) { return base::autoResizeTestSet( pos, val ); }
198
200 template <typename M>
201 [[nodiscard]] TypedBitSet getMapping( const M & map ) const;
202 [[nodiscard]] TypedBitSet getMapping( const Vector<IndexType, IndexType> & map ) const
203 { return getMapping( [&map]( IndexType i ) { return map[i]; } ); }
204 [[nodiscard]] TypedBitSet getMapping( const BMap<IndexType, IndexType> & map ) const
205 { return getMapping( [&map]( IndexType i ) { return map.b[i]; }, map.tsize ); }
206 [[nodiscard]] TypedBitSet getMapping( const HashMap<IndexType, IndexType> & map ) const
207 { return getMapping( [&map]( IndexType i ) { return getAt( map, i ); } ); }
209 template <typename M>
210 [[nodiscard]] TypedBitSet getMapping( const M & map, size_t resSize ) const;
211 [[nodiscard]] TypedBitSet getMapping( const Vector<IndexType, IndexType> & map, size_t resSize ) const
212 { return getMapping( [&map]( IndexType i ) { return map[i]; }, resSize ); }
213 [[nodiscard]] TypedBitSet getMapping( const HashMap<IndexType, IndexType> & map, size_t resSize ) const
214 { return getMapping( [&map]( IndexType i ) { return getAt( map, i ); }, resSize ); }
215
217 [[nodiscard]] IndexType backId() const { assert( !empty() ); return IndexType{ size() - 1 }; }
218
220 [[nodiscard]] static IndexType beginId() { return IndexType{ size_t( 0 ) }; }
221 [[nodiscard]] IndexType endId() const { return IndexType{ size() }; }
222};
223
224
226[[nodiscard]] inline size_t heapBytes( const BitSet& bs )
227{
228 return bs.heapBytes();
229}
230
232[[nodiscard]] MRMESH_API bool operator == ( const BitSet & a, const BitSet & b );
233template <typename I>
234[[nodiscard]] inline bool operator == ( const TypedBitSet<I> & a, const TypedBitSet<I> & b )
235 { return static_cast<const BitSet &>( a ) == static_cast<const BitSet &>( b ); }
237template <typename T, typename U>
238void operator == ( const TypedBitSet<T> & a, const TypedBitSet<U> & b ) = delete;
239
240template <typename I>
241[[nodiscard]] inline std::function<bool( I )> makePredicate( const TypedBitSet<I> * bitset )
242{
243 std::function<bool( I )> res;
244 if ( bitset )
245 res = [bitset]( I id ) { return bitset->test( id ); };
246 return res;
247}
248
249template <typename I>
250[[nodiscard]] inline std::function<bool( I )> makePredicate( const TypedBitSet<I> & bitset )
251 { return makePredicate( &bitset ); }
252
253template <typename I>
254[[nodiscard]] inline bool contains( const TypedBitSet<I> * bitset, I id )
255{
256 return id.valid() && ( !bitset || bitset->test( id ) );
257}
258
259template <typename I>
260[[nodiscard]] inline bool contains( const TypedBitSet<I> & bitset, I id )
261{
262 return id.valid() && bitset.test( id );
263}
264
266template <typename T>
268{
269public:
270 using IndexType = typename T::IndexType;
271
272 using iterator_category = std::forward_iterator_tag;
274 using difference_type = std::ptrdiff_t;
275 using reference = const IndexType;
276 using pointer = const IndexType *;
277
279 SetBitIteratorT() = default;
281 SetBitIteratorT( const T & bitset )
282 : bitset_( &bitset ), index_( bitset.find_first() )
283 {
284 }
286 {
287 index_ = bitset_->find_next( index_ );
288 return * this;
289 }
290 [[nodiscard]] SetBitIteratorT operator++( int )
291 {
292 SetBitIteratorT ret = *this;
293 operator++();
294 return ret;
295 }
296
297 [[nodiscard]] const T * bitset() const { return bitset_; }
298 [[nodiscard]] reference operator *() const { return index_; }
299
300 [[nodiscard]] friend bool operator ==( const SetBitIteratorT<T> & a, const SetBitIteratorT<T> & b ) { return *a == *b; }
301
302private:
303 const T * bitset_ = nullptr;
304 IndexType index_ = IndexType( ~size_t( 0 ) );
305};
306
307
308[[nodiscard]] MR_BIND_IGNORE inline auto begin( const BitSet & a )
309 { return SetBitIteratorT<BitSet>(a); }
310[[nodiscard]] MR_BIND_IGNORE inline auto end( const BitSet & )
311 { return SetBitIteratorT<BitSet>(); }
312
313template <typename I>
314[[nodiscard]] MR_BIND_IGNORE inline auto begin( const TypedBitSet<I> & a )
315 { return SetBitIteratorT<TypedBitSet<I>>(a); }
316template <typename I>
317[[nodiscard]] MR_BIND_IGNORE inline auto end( const TypedBitSet<I> & )
318 { return SetBitIteratorT<TypedBitSet<I>>(); }
319
321template <typename I>
323{
324 Vector<int, I> res( bs.size(), -1 );
325 int n = 0;
326 for ( auto v : bs )
327 res[v] = n++;
328 return res;
329}
330
332template <typename I>
334{
335 HashMap<I, int> res;
336 int n = 0;
337 for ( auto v : bs )
338 res[v] = n++;
339 return res;
340}
341
342template <typename I>
343template <typename M>
344[[nodiscard]] TypedBitSet<I> TypedBitSet<I>::getMapping( const M & map ) const
345{
346 TypedBitSet<I> res;
347 for ( auto b : *this )
348 if ( auto mapped = map( b ) )
349 res.autoResizeSet( mapped );
350 return res;
351}
352
353template <typename I>
354template <typename M>
355[[nodiscard]] TypedBitSet<I> TypedBitSet<I>::getMapping( const M & map, size_t resSize ) const
356{
357 TypedBitSet<I> res;
358 if ( !any() )
359 return res;
360 res.resize( resSize );
361 for ( auto b : *this )
362 if ( auto mapped = map( b ) )
363 res.set( mapped );
364 return res;
365}
366
367[[nodiscard]] inline BitSet operator & ( const BitSet & a, const BitSet & b ) { BitSet res{ a }; res &= b; return res; }
368[[nodiscard]] inline BitSet operator | ( const BitSet & a, const BitSet & b ) { BitSet res{ a }; res |= b; return res; }
369[[nodiscard]] inline BitSet operator ^ ( const BitSet & a, const BitSet & b ) { BitSet res{ a }; res ^= b; return res; }
370[[nodiscard]] inline BitSet operator - ( const BitSet & a, const BitSet & b ) { BitSet res{ a }; res -= b; return res; }
371
373
374} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
#define M(T)
Definition MRMesh/MRBitSet.h:28
size_t IndexType
Definition MRMesh/MRBitSet.h:32
IndexType endId() const
Definition MRMesh/MRBitSet.h:119
boost::dynamic_bitset< std::uint64_t > base
Definition MRMesh/MRBitSet.h:30
static IndexType beginId()
[beginId(), endId()) is the range of all bits in the set
Definition MRMesh/MRBitSet.h:118
MRMESH_API IndexType find_last() const
return the highest index i such as bit i is set, or npos if *this has no on bits.
BitSet & reset()
Definition MRMesh/MRBitSet.h:52
MRMESH_API size_t nthSetBit(size_t n) const
returns the location of nth set bit (where the first bit corresponds to n=0) or npos if there are les...
MRMESH_API BitSet & subtract(const BitSet &b, int bShiftInBlocks)
subtracts b from this, considering that bits in b are shifted right on bShiftInBlocks*bits_per_block
MRMESH_API BitSet & operator-=(const BitSet &b)
bool is_proper_subset_of(const BitSet &a) const =delete
returns true if, for every bit that is set in this bitset, the corresponding bit in bitset a is also ...
BitSet(size_t, unsigned long)=delete
prohibit these constructors inherited from boost::dynamic_bitset, which can initialize only few initi...
BitSet & set(IndexType n, size_type len, bool val)
Definition MRMesh/MRBitSet.h:46
BitSet & set()
Definition MRMesh/MRBitSet.h:49
BitSet & set(IndexType n)
Definition MRMesh/MRBitSet.h:48
void autoResizeSet(size_t pos, bool val=true)
Definition MRMesh/MRBitSet.h:100
BitSet & reset(IndexType n, size_type len)
Definition MRMesh/MRBitSet.h:50
bool autoResizeTestSet(size_t pos, bool val=true)
same as autoResizeSet and returns previous value of pos-bit
Definition MRMesh/MRBitSet.h:103
bool test_set(IndexType n, bool val=true)
Definition MRMesh/MRBitSet.h:44
BitSet & flip(IndexType n, size_type len)
Definition MRMesh/MRBitSet.h:53
BitSet & reset(IndexType n)
Definition MRMesh/MRBitSet.h:51
bool test(IndexType n) const
Definition MRMesh/MRBitSet.h:43
BitSet & flip()
Definition MRMesh/MRBitSet.h:55
void autoResizeSet(size_t pos, size_type len, bool val=true)
sets elements [pos, pos+len) to given value, adjusting the size of the set to include new elements
Definition MRMesh/MRBitSet.h:94
BitSet & set(IndexType n, bool val)
Definition MRMesh/MRBitSet.h:47
IndexType backId() const
returns the identifier of the back() element
Definition MRMesh/MRBitSet.h:115
void resizeWithReserve(size_t newSize)
doubles reserved memory until resize(newSize) can be done without reallocation
Definition MRMesh/MRBitSet.h:81
MRMESH_API bool is_subset_of(const BitSet &a) const
returns true if, for every bit that is set in this bitset, the corresponding bit in bitset a is also ...
const auto & bits() const
read-only access to all bits stored as a vector of uint64 blocks
Definition MRMesh/MRBitSet.h:58
BitSet(T, T)=delete
size_t heapBytes() const
returns the amount of memory this object occupies on heap
Definition MRMesh/MRBitSet.h:112
BitSet(size_t numBits, bool fillValue)
creates bitset of given size filled with given value
Definition MRMesh/MRBitSet.h:35
MRMESH_API BitSet & operator|=(const BitSet &b)
MRMESH_API BitSet & operator^=(const BitSet &b)
MRMESH_API BitSet & operator&=(const BitSet &b)
BitSet & flip(IndexType n)
Definition MRMesh/MRBitSet.h:54
iterator to enumerate all indices with set bits in BitSet class or its derivatives
Definition MRMesh/MRBitSet.h:268
SetBitIteratorT operator++(int)
Definition MRMesh/MRBitSet.h:290
const IndexType * pointer
Definition MRMesh/MRBitSet.h:276
SetBitIteratorT()=default
constructs end iterator
std::forward_iterator_tag iterator_category
Definition MRMesh/MRBitSet.h:272
const T * bitset() const
Definition MRMesh/MRBitSet.h:297
IndexType value_type
Definition MRMesh/MRBitSet.h:273
const IndexType reference
intentionally not a reference
Definition MRMesh/MRBitSet.h:275
typename T::IndexType IndexType
Definition MRMesh/MRBitSet.h:270
SetBitIteratorT & operator++()
Definition MRMesh/MRBitSet.h:285
SetBitIteratorT(const T &bitset)
constructs begin iterator
Definition MRMesh/MRBitSet.h:281
std::ptrdiff_t difference_type
Definition MRMesh/MRBitSet.h:274
Definition MRMesh/MRBitSet.h:141
IndexType find_last() const
Definition MRMesh/MRBitSet.h:172
TypedBitSet & operator|=(const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:177
bool intersects(const TypedBitSet &a) const
returns true if, there is a bit which is set in this bitset, such that the corresponding bit in bitse...
Definition MRMesh/MRBitSet.h:193
bool test_set(IndexType n, bool val=true)
Definition MRMesh/MRBitSet.h:164
TypedBitSet getMapping(const HashMap< IndexType, IndexType > &map) const
Definition MRMesh/MRBitSet.h:206
friend TypedBitSet operator|(const TypedBitSet &a, const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:182
friend TypedBitSet operator&(const TypedBitSet &a, const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:181
static IndexType beginId()
[beginId(), endId()) is the range of all bits in the set
Definition MRMesh/MRBitSet.h:220
TypedBitSet(const BitSet &src)
copies all bits from another BitSet (or a descending class, e.g. TypedBitSet)
Definition MRMesh/MRBitSet.h:148
TypedBitSet & flip(IndexType n)
Definition MRMesh/MRBitSet.h:161
IndexType backId() const
returns the identifier of the back() element
Definition MRMesh/MRBitSet.h:217
MR_BIND_IGNORE reference operator[](IndexType pos)
Definition MRMesh/MRBitSet.h:167
TypedBitSet getMapping(const HashMap< IndexType, IndexType > &map, size_t resSize) const
Definition MRMesh/MRBitSet.h:213
TypedBitSet & operator-=(const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:179
TypedBitSet & set(IndexType n, size_type len, bool val)
Definition MRMesh/MRBitSet.h:153
bool is_subset_of(const TypedBitSet &a) const
returns true if, for every bit that is set in this bitset, the corresponding bit in bitset a is also ...
Definition MRMesh/MRBitSet.h:190
TypedBitSet & reset(IndexType n, size_type len)
Definition MRMesh/MRBitSet.h:157
friend TypedBitSet operator-(const TypedBitSet &a, const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:184
TypedBitSet & operator^=(const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:178
TypedBitSet & set()
Definition MRMesh/MRBitSet.h:156
void autoResizeSet(IndexType pos, size_type len, bool val=true)
Definition MRMesh/MRBitSet.h:195
bool operator[](IndexType pos) const
Definition MRMesh/MRBitSet.h:168
IndexType endId() const
Definition MRMesh/MRBitSet.h:221
I IndexType
Definition MRMesh/MRBitSet.h:145
TypedBitSet & flip()
Definition MRMesh/MRBitSet.h:162
TypedBitSet getMapping(const Vector< IndexType, IndexType > &map, size_t resSize) const
Definition MRMesh/MRBitSet.h:211
IndexType find_first() const
Definition MRMesh/MRBitSet.h:170
friend TypedBitSet operator^(const TypedBitSet &a, const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:183
TypedBitSet & set(IndexType n, bool val)
Definition MRMesh/MRBitSet.h:154
TypedBitSet & flip(IndexType n, size_type len)
Definition MRMesh/MRBitSet.h:160
TypedBitSet & operator&=(const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:176
TypedBitSet getMapping(const M &map, size_t resSize) const
this is a faster version if the result size is known beforehand
void autoResizeSet(IndexType pos, bool val=true)
Definition MRMesh/MRBitSet.h:196
IndexType find_next(IndexType pos) const
Definition MRMesh/MRBitSet.h:171
TypedBitSet & reset()
Definition MRMesh/MRBitSet.h:159
bool autoResizeTestSet(IndexType pos, bool val=true)
Definition MRMesh/MRBitSet.h:197
TypedBitSet(BitSet &&src)
moves all bits from another BitSet (or a descending class, e.g. TypedBitSet)
Definition MRMesh/MRBitSet.h:151
TypedBitSet & set(IndexType n)
Definition MRMesh/MRBitSet.h:155
TypedBitSet & subtract(const TypedBitSet &b, int bShiftInBlocks)
subtracts b from this, considering that bits in b are shifted right on bShiftInBlocks*bits_per_block
Definition MRMesh/MRBitSet.h:187
TypedBitSet getMapping(const Vector< IndexType, IndexType > &map) const
Definition MRMesh/MRBitSet.h:202
TypedBitSet & reset(IndexType n)
Definition MRMesh/MRBitSet.h:158
TypedBitSet getMapping(const M &map) const
constructs another bit set from this where every set bit index is transformed using given map
IndexType nthSetBit(size_t n) const
returns the location of nth set bit (where the first bit corresponds to n=0) or IndexType(npos) if th...
Definition MRMesh/MRBitSet.h:174
bool test(IndexType n) const
Definition MRMesh/MRBitSet.h:163
TypedBitSet getMapping(const BMap< IndexType, IndexType > &map) const
Definition MRMesh/MRBitSet.h:204
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:19
BitSet operator-(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:370
MR_BIND_IGNORE auto begin(const BitSet &a)
Definition MRMesh/MRBitSet.h:308
HashMap< I, int > makeHashMapWithSeqNums(const TypedBitSet< I > &bs)
creates a HashMap where for each set bit of input bitset its sequential number starting from 0 is ret...
Definition MRMesh/MRBitSet.h:333
MRMESH_API bool operator==(const BitSet &a, const BitSet &b)
compare that two bit sets have the same set bits (they can be equal even if sizes are distinct but la...
BitSet operator&(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:367
Vector< int, I > makeVectorWithSeqNums(const TypedBitSet< I > &bs)
creates a Vector where for each set bit of input bitset its sequential number starting from 0 is retu...
Definition MRMesh/MRBitSet.h:322
bool contains(const TypedBitSet< I > *bitset, I id)
Definition MRMesh/MRBitSet.h:254
BitSet operator|(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:368
MR_BIND_IGNORE auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:310
std::function< bool(I)> makePredicate(const TypedBitSet< I > *bitset)
Definition MRMesh/MRBitSet.h:241
BitSet operator^(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:369
size_t heapBytes(const BitSet &bs)
returns the amount of memory given BitSet occupies on heap
Definition MRMesh/MRBitSet.h:226
Definition MRCameraOrientationPlugin.h:8
class MRMESH_CLASS BitSet
Definition MRMesh/MRMeshFwd.h:144
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:29
T getAt(const Buffer< T, I > &bmap, I key, T def={})
given some buffer map and a key, returns the value associated with the key, or default value if key i...
Definition MRBuffer.h:119
Color operator*(float a, const Color &b)
Definition MRMesh/MRColor.h:116
I
Definition MRMesh/MRMeshFwd.h:130
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:10
phmap::flat_hash_map< K, V, Hash, Eq > HashMap
Definition MRMesh/MRMeshFwd.h:592
flat map: I -> T
Definition MRBuffer.h:143
Buffer< T, I > b
Definition MRBuffer.h:144
size_t tsize
target size, all values inside b must be less than this value
Definition MRBuffer.h:145