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
26class BitSet : public boost::dynamic_bitset<std::uint64_t>
27{
28public:
29 using base = boost::dynamic_bitset<std::uint64_t>;
30 using base::base;
31 using IndexType = size_t;
32
34 explicit BitSet( size_t numBits, bool fillValue ) { resize( numBits, fillValue ); }
35
37 explicit BitSet( size_t, unsigned long ) = delete;
38 template<class T, std::enable_if_t<std::is_arithmetic<T>::value, std::nullptr_t> = nullptr>
39 explicit BitSet( T, T ) = delete;
40
41 // all bits after size() we silently consider as not-set
42 [[nodiscard]] bool test( IndexType n ) const { return n < size() && base::test( n ); }
43 [[nodiscard]] bool test_set( IndexType n, bool val = true ) { return ( val || n < size() ) ? base::test_set( n, val ) : false; }
44
45 BitSet & set( IndexType n, size_type len, bool val ) { base::set( n, len, val ); return * this; }
46 BitSet & set( IndexType n, bool val = true ) { base::set( n, val ); return * this; }
47 BitSet & set() { base::set(); return * this; }
48 BitSet & reset( IndexType n, size_type len ) { if ( n < size() ) base::reset( n, len ); return * this; }
49 BitSet & reset( IndexType n ) { if ( n < size() ) base::reset( n ); return * this; }
50 BitSet & reset() { base::reset(); return * this; }
51 BitSet & flip( IndexType n, size_type len ) { base::flip( n, len ); return * this; }
52 BitSet & flip( IndexType n ) { base::flip( n ); return * this; }
53 BitSet & flip() { base::flip(); return * this; }
54
56 const auto & bits() const { return m_bits; }
57
61
64 MRMESH_API BitSet & subtract( const BitSet & b, int bShiftInBlocks );
65
67 [[nodiscard]] MRMESH_API IndexType find_last() const;
68
70 [[nodiscard]] MRMESH_API size_t nthSetBit( size_t n ) const;
71
73 void resizeWithReserve( size_t newSize )
74 {
75 auto reserved = capacity();
76 if ( reserved > 0 && newSize > reserved )
77 {
78 while ( newSize > reserved )
79 reserved <<= 1;
80 reserve( reserved );
81 }
82 resize( newSize );
83 }
84
86 void autoResizeSet( size_t pos, size_type len, bool val = true )
87 {
88 if ( pos + len > size() )
89 resizeWithReserve( pos + len );
90 set( pos, len, val );
91 }
92 void autoResizeSet( size_t pos, bool val = true ) { autoResizeSet( pos, 1, val ); }
93
95 [[nodiscard]] bool autoResizeTestSet( size_t pos, bool val = true )
96 {
97 bool const b = test( pos );
98 if ( b != val )
99 autoResizeSet( pos, val );
100 return b;
101 }
102
104 [[nodiscard]] size_t heapBytes() const { return capacity() / 8; }
105
107 [[nodiscard]] IndexType backId() const { assert( !empty() ); return IndexType{ size() - 1 }; }
108
110 [[nodiscard]] static IndexType beginId() { return IndexType{ 0 }; }
111 [[nodiscard]] IndexType endId() const { return IndexType{ size() }; }
112
113 // Normally those are inherited from `boost::dynamic_bitset`, but MRBind currently chokes on it, so we provide those manually.
114 #if defined(MR_PARSING_FOR_PB11_BINDINGS) || defined(MR_COMPILING_PB11_BINDINGS)
115 std::size_t size() const { return dynamic_bitset::size(); }
116 std::size_t count() const { return dynamic_bitset::count(); }
117 void resize( std::size_t num_bits, bool value = false ) { dynamic_bitset::resize( num_bits, value ); }
118 void clear() { dynamic_bitset::clear(); }
119 void push_back( bool bit ) { dynamic_bitset::push_back( bit ); }
120 void pop_back() { dynamic_bitset::pop_back(); }
121 #endif
122
123private:
124 using base::m_highest_block;
125 using base::m_bits;
126 using base::m_num_bits;
127};
128
130template <typename I>
131class TypedBitSet : public BitSet
132{
133 using base = BitSet;
134public:
135 using base::base;
136 using IndexType = I;
137
139 explicit TypedBitSet( const BitSet & src ) : BitSet( src ) {}
140
142 explicit TypedBitSet( BitSet && src ) : BitSet( std::move( src ) ) {}
143
144 TypedBitSet & set( IndexType n, size_type len, bool val ) { base::set( n, len, val ); return * this; }
145 TypedBitSet & set( IndexType n, bool val = true ) { base::set( n, val ); return * this; }
146 TypedBitSet & set() { base::set(); return * this; }
147 TypedBitSet & reset( IndexType n, size_type len ) { base::reset( n, len ); return * this; }
148 TypedBitSet & reset( IndexType n ) { base::reset( n ); return * this; }
149 TypedBitSet & reset() { base::reset(); return * this; }
150 TypedBitSet & flip( IndexType n, size_type len ) { base::flip( n, len ); return * this; }
151 TypedBitSet & flip( IndexType n ) { base::flip( n ); return * this; }
152 TypedBitSet & flip() { base::flip(); return * this; }
153 [[nodiscard]] bool test( IndexType n ) const { return base::test( n ); }
154 [[nodiscard]] bool test_set( IndexType n, bool val = true ) { return base::test_set( n, val ); }
155
156 // Disable for python bindings, because MRBind chokes on `boost::dynamic_bitset::reference`.
157 [[nodiscard]] MR_BIND_IGNORE reference operator[]( IndexType pos ) { return base::operator[]( pos ); }
158 [[nodiscard]] bool operator[]( IndexType pos ) const { return base::operator[]( pos ); }
159
160 [[nodiscard]] IndexType find_first() const { return IndexType( base::find_first() ); }
161 [[nodiscard]] IndexType find_next( IndexType pos ) const { return IndexType( base::find_next( pos ) ); }
162 [[nodiscard]] IndexType find_last() const { return IndexType( base::find_last() ); }
164 [[nodiscard]] IndexType nthSetBit( size_t n ) const { return IndexType( base::nthSetBit( n ) ); }
165
166 TypedBitSet & operator &= ( const TypedBitSet & b ) { base::operator &= ( b ); return * this; }
167 TypedBitSet & operator |= ( const TypedBitSet & b ) { base::operator |= ( b ); return * this; }
168 TypedBitSet & operator ^= ( const TypedBitSet & b ) { base::operator ^= ( b ); return * this; }
169 TypedBitSet & operator -= ( const TypedBitSet & b ) { base::operator -= ( b ); return * this; }
170
171 [[nodiscard]] friend TypedBitSet operator & ( const TypedBitSet & a, const TypedBitSet & b ) { auto res{ a }; res &= b; return res; }
172 [[nodiscard]] friend TypedBitSet operator | ( const TypedBitSet & a, const TypedBitSet & b ) { auto res{ a }; res |= b; return res; }
173 [[nodiscard]] friend TypedBitSet operator ^ ( const TypedBitSet & a, const TypedBitSet & b ) { auto res{ a }; res ^= b; return res; }
174 [[nodiscard]] friend TypedBitSet operator - ( const TypedBitSet & a, const TypedBitSet & b ) { auto res{ a }; res -= b; return res; }
175
177 TypedBitSet & subtract( const TypedBitSet & b, int bShiftInBlocks ) { base::subtract( b, bShiftInBlocks ); return * this; }
178
180 bool is_subset_of( const TypedBitSet& a ) const { return base::is_subset_of( a ); }
181
183 bool is_proper_subset_of( const TypedBitSet& a ) const { return base::is_proper_subset_of( a ); }
184
186 bool intersects( const TypedBitSet & a ) const { return base::intersects( a ); }
187
188 void autoResizeSet( IndexType pos, size_type len, bool val = true ) { base::autoResizeSet( pos, len, val ); }
189 void autoResizeSet( IndexType pos, bool val = true ) { base::autoResizeSet( pos, val ); }
190 [[nodiscard]] bool autoResizeTestSet( IndexType pos, bool val = true ) { return base::autoResizeTestSet( pos, val ); }
191
193 template <typename M>
194 [[nodiscard]] TypedBitSet getMapping( const M & map ) const;
195 [[nodiscard]] TypedBitSet getMapping( const Vector<IndexType, IndexType> & map ) const
196 { return getMapping( [&map]( IndexType i ) { return map[i]; } ); }
197 [[nodiscard]] TypedBitSet getMapping( const BMap<IndexType, IndexType> & map ) const
198 { return getMapping( [&map]( IndexType i ) { return map.b[i]; }, map.tsize ); }
199 [[nodiscard]] TypedBitSet getMapping( const HashMap<IndexType, IndexType> & map ) const
200 { return getMapping( [&map]( IndexType i ) { return getAt( map, i ); } ); }
202 template <typename M>
203 [[nodiscard]] TypedBitSet getMapping( const M & map, size_t resSize ) const;
204 [[nodiscard]] TypedBitSet getMapping( const Vector<IndexType, IndexType> & map, size_t resSize ) const
205 { return getMapping( [&map]( IndexType i ) { return map[i]; }, resSize ); }
206 [[nodiscard]] TypedBitSet getMapping( const HashMap<IndexType, IndexType> & map, size_t resSize ) const
207 { return getMapping( [&map]( IndexType i ) { return getAt( map, i ); }, resSize ); }
208
210 [[nodiscard]] IndexType backId() const { assert( !empty() ); return IndexType{ size() - 1 }; }
211
213 [[nodiscard]] static IndexType beginId() { return IndexType{ size_t( 0 ) }; }
214 [[nodiscard]] IndexType endId() const { return IndexType{ size() }; }
215};
216
217
219[[nodiscard]] inline size_t heapBytes( const BitSet& bs )
220{
221 return bs.heapBytes();
222}
223
225[[nodiscard]] MRMESH_API bool operator == ( const BitSet & a, const BitSet & b );
226template <typename I>
227[[nodiscard]] inline bool operator == ( const TypedBitSet<I> & a, const TypedBitSet<I> & b )
228 { return static_cast<const BitSet &>( a ) == static_cast<const BitSet &>( b ); }
230template <typename T, typename U>
231void operator == ( const TypedBitSet<T> & a, const TypedBitSet<U> & b ) = delete;
232
233template <typename I>
234[[nodiscard]] inline std::function<bool( I )> makePredicate( const TypedBitSet<I> * bitset )
235{
236 std::function<bool( I )> res;
237 if ( bitset )
238 res = [bitset]( I id ) { return bitset->test( id ); };
239 return res;
240}
241
242template <typename I>
243[[nodiscard]] inline std::function<bool( I )> makePredicate( const TypedBitSet<I> & bitset )
244 { return makePredicate( &bitset ); }
245
246template <typename I>
247[[nodiscard]] inline bool contains( const TypedBitSet<I> * bitset, I id )
248{
249 return id.valid() && ( !bitset || bitset->test( id ) );
250}
251
252template <typename I>
253[[nodiscard]] inline bool contains( const TypedBitSet<I> & bitset, I id )
254{
255 return id.valid() && bitset.test( id );
256}
257
259template <typename T>
260class MR_BIND_IGNORE SetBitIteratorT
261{
262public:
263 using IndexType = typename T::IndexType;
264
265 using iterator_category = std::forward_iterator_tag;
267 using difference_type = std::ptrdiff_t;
268 using reference = const IndexType;
269 using pointer = const IndexType *;
270
272 SetBitIteratorT() = default;
274 SetBitIteratorT( const T & bitset )
275 : bitset_( &bitset ), index_( bitset.find_first() )
276 {
277 }
279 {
280 index_ = bitset_->find_next( index_ );
281 return * this;
282 }
283 [[nodiscard]] SetBitIteratorT operator++( int )
284 {
285 SetBitIteratorT ret = *this;
286 operator++();
287 return ret;
288 }
289
290 [[nodiscard]] const T * bitset() const { return bitset_; }
291 [[nodiscard]] reference operator *() const { return index_; }
292
293private:
294 const T * bitset_ = nullptr;
295 IndexType index_ = IndexType( ~size_t( 0 ) );
296};
297
298template <typename T>
299[[nodiscard]] MR_BIND_IGNORE inline bool operator ==( const SetBitIteratorT<T> & a, const SetBitIteratorT<T> & b )
300 { return *a == *b; }
301
302template <typename T>
303[[nodiscard]] MR_BIND_IGNORE inline bool operator !=( const SetBitIteratorT<T> & a, const SetBitIteratorT<T> & b )
304 { return *a != *b; }
305
306
307[[nodiscard]] MR_BIND_IGNORE inline auto begin( const BitSet & a )
308 { return SetBitIteratorT<BitSet>(a); }
309[[nodiscard]] MR_BIND_IGNORE inline auto end( const BitSet & )
310 { return SetBitIteratorT<BitSet>(); }
311
312template <typename I>
313[[nodiscard]] MR_BIND_IGNORE inline auto begin( const TypedBitSet<I> & a )
314 { return SetBitIteratorT<TypedBitSet<I>>(a); }
315template <typename I>
316[[nodiscard]] MR_BIND_IGNORE inline auto end( const TypedBitSet<I> & )
317 { return SetBitIteratorT<TypedBitSet<I>>(); }
318
320template <typename I>
322{
323 Vector<int, I> res( bs.size(), -1 );
324 int n = 0;
325 for ( auto v : bs )
326 res[v] = n++;
327 return res;
328}
329
331template <typename I>
333{
334 HashMap<I, int> res;
335 int n = 0;
336 for ( auto v : bs )
337 res[v] = n++;
338 return res;
339}
340
341template <typename I>
342template <typename M>
343[[nodiscard]] TypedBitSet<I> TypedBitSet<I>::getMapping( const M & map ) const
344{
345 TypedBitSet<I> res;
346 for ( auto b : *this )
347 if ( auto mapped = map( b ) )
348 res.autoResizeSet( mapped );
349 return res;
350}
351
352template <typename I>
353template <typename M>
354[[nodiscard]] TypedBitSet<I> TypedBitSet<I>::getMapping( const M & map, size_t resSize ) const
355{
356 TypedBitSet<I> res;
357 if ( !any() )
358 return res;
359 res.resize( resSize );
360 for ( auto b : *this )
361 if ( auto mapped = map( b ) )
362 res.set( mapped );
363 return res;
364}
365
366[[nodiscard]] inline BitSet operator & ( const BitSet & a, const BitSet & b ) { BitSet res{ a }; res &= b; return res; }
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
372
373} // namespace MR
constexpr auto operator*(A a, B b)
Definition MRImGuiVectorOperators.h:107
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
#define M(T)
container of bits
Definition MRMesh/MRBitSet.h:27
size_t IndexType
Definition MRMesh/MRBitSet.h:31
IndexType endId() const
Definition MRMesh/MRBitSet.h:111
boost::dynamic_bitset< std::uint64_t > base
Definition MRMesh/MRBitSet.h:29
static IndexType beginId()
[beginId(), endId()) is the range of all bits in the set
Definition MRMesh/MRBitSet.h:110
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:50
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)
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:45
BitSet & set()
Definition MRMesh/MRBitSet.h:47
void autoResizeSet(size_t pos, bool val=true)
Definition MRMesh/MRBitSet.h:92
BitSet & reset(IndexType n, size_type len)
Definition MRMesh/MRBitSet.h:48
BitSet & set(IndexType n, bool val=true)
Definition MRMesh/MRBitSet.h:46
bool autoResizeTestSet(size_t pos, bool val=true)
same as autoResizeSet and returns previous value of pos-bit
Definition MRMesh/MRBitSet.h:95
bool test_set(IndexType n, bool val=true)
Definition MRMesh/MRBitSet.h:43
BitSet & flip(IndexType n, size_type len)
Definition MRMesh/MRBitSet.h:51
BitSet & reset(IndexType n)
Definition MRMesh/MRBitSet.h:49
bool test(IndexType n) const
Definition MRMesh/MRBitSet.h:42
BitSet & flip()
Definition MRMesh/MRBitSet.h:53
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:86
IndexType backId() const
returns the identifier of the back() element
Definition MRMesh/MRBitSet.h:107
void resizeWithReserve(size_t newSize)
doubles reserved memory until resize(newSize) can be done without reallocation
Definition MRMesh/MRBitSet.h:73
const auto & bits() const
read-only access to all bits stored as a vector of uint64 blocks
Definition MRMesh/MRBitSet.h:56
BitSet(T, T)=delete
size_t heapBytes() const
returns the amount of memory this object occupies on heap
Definition MRMesh/MRBitSet.h:104
BitSet(size_t numBits, bool fillValue)
creates bitset of given size filled with given value
Definition MRMesh/MRBitSet.h:34
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:52
iterator to enumerate all indices with set bits in BitSet class or its derivatives
Definition MRMesh/MRBitSet.h:261
SetBitIteratorT operator++(int)
Definition MRMesh/MRBitSet.h:283
const IndexType * pointer
Definition MRMesh/MRBitSet.h:269
SetBitIteratorT()=default
constructs end iterator
std::forward_iterator_tag iterator_category
Definition MRMesh/MRBitSet.h:265
const T * bitset() const
Definition MRMesh/MRBitSet.h:290
IndexType value_type
Definition MRMesh/MRBitSet.h:266
const IndexType reference
intentionally not a reference
Definition MRMesh/MRBitSet.h:268
typename T::IndexType IndexType
Definition MRMesh/MRBitSet.h:263
SetBitIteratorT & operator++()
Definition MRMesh/MRBitSet.h:278
SetBitIteratorT(const T &bitset)
constructs begin iterator
Definition MRMesh/MRBitSet.h:274
std::ptrdiff_t difference_type
Definition MRMesh/MRBitSet.h:267
container of bits representing specific indices (faces, verts or edges)
Definition MRMesh/MRBitSet.h:132
IndexType find_last() const
Definition MRMesh/MRBitSet.h:162
TypedBitSet & operator|=(const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:167
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:186
bool test_set(IndexType n, bool val=true)
Definition MRMesh/MRBitSet.h:154
TypedBitSet getMapping(const HashMap< IndexType, IndexType > &map) const
Definition MRMesh/MRBitSet.h:199
friend TypedBitSet operator|(const TypedBitSet &a, const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:172
friend TypedBitSet operator&(const TypedBitSet &a, const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:171
static IndexType beginId()
[beginId(), endId()) is the range of all bits in the set
Definition MRMesh/MRBitSet.h:213
TypedBitSet(const BitSet &src)
copies all bits from another BitSet (or a descending class, e.g. TypedBitSet)
Definition MRMesh/MRBitSet.h:139
TypedBitSet & flip(IndexType n)
Definition MRMesh/MRBitSet.h:151
IndexType backId() const
returns the identifier of the back() element
Definition MRMesh/MRBitSet.h:210
MR_BIND_IGNORE reference operator[](IndexType pos)
Definition MRMesh/MRBitSet.h:157
TypedBitSet getMapping(const HashMap< IndexType, IndexType > &map, size_t resSize) const
Definition MRMesh/MRBitSet.h:206
TypedBitSet & operator-=(const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:169
TypedBitSet & set(IndexType n, size_type len, bool val)
Definition MRMesh/MRBitSet.h:144
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:180
TypedBitSet & reset(IndexType n, size_type len)
Definition MRMesh/MRBitSet.h:147
friend TypedBitSet operator-(const TypedBitSet &a, const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:174
TypedBitSet & operator^=(const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:168
TypedBitSet & set()
Definition MRMesh/MRBitSet.h:146
void autoResizeSet(IndexType pos, size_type len, bool val=true)
Definition MRMesh/MRBitSet.h:188
bool operator[](IndexType pos) const
Definition MRMesh/MRBitSet.h:158
IndexType endId() const
Definition MRMesh/MRBitSet.h:214
I IndexType
Definition MRMesh/MRBitSet.h:136
TypedBitSet & flip()
Definition MRMesh/MRBitSet.h:152
TypedBitSet getMapping(const Vector< IndexType, IndexType > &map, size_t resSize) const
Definition MRMesh/MRBitSet.h:204
IndexType find_first() const
Definition MRMesh/MRBitSet.h:160
friend TypedBitSet operator^(const TypedBitSet &a, const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:173
TypedBitSet & flip(IndexType n, size_type len)
Definition MRMesh/MRBitSet.h:150
TypedBitSet & operator&=(const TypedBitSet &b)
Definition MRMesh/MRBitSet.h:166
bool is_proper_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:183
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:189
IndexType find_next(IndexType pos) const
Definition MRMesh/MRBitSet.h:161
TypedBitSet & reset()
Definition MRMesh/MRBitSet.h:149
bool autoResizeTestSet(IndexType pos, bool val=true)
Definition MRMesh/MRBitSet.h:190
TypedBitSet(BitSet &&src)
moves all bits from another BitSet (or a descending class, e.g. TypedBitSet)
Definition MRMesh/MRBitSet.h:142
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:177
TypedBitSet getMapping(const Vector< IndexType, IndexType > &map) const
Definition MRMesh/MRBitSet.h:195
TypedBitSet & reset(IndexType n)
Definition MRMesh/MRBitSet.h:148
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:164
bool test(IndexType n) const
Definition MRMesh/MRBitSet.h:153
TypedBitSet getMapping(const BMap< IndexType, IndexType > &map) const
Definition MRMesh/MRBitSet.h:197
TypedBitSet & set(IndexType n, bool val=true)
Definition MRMesh/MRBitSet.h:145
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:369
MR_BIND_IGNORE auto begin(const BitSet &a)
Definition MRMesh/MRBitSet.h:307
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:332
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:366
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:321
bool contains(const TypedBitSet< I > *bitset, I id)
Definition MRMesh/MRBitSet.h:247
BitSet operator|(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:367
MR_BIND_IGNORE bool operator!=(const SetBitIteratorT< T > &a, const SetBitIteratorT< T > &b)
Definition MRMesh/MRBitSet.h:303
MR_BIND_IGNORE auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:309
std::function< bool(I)> makePredicate(const TypedBitSet< I > *bitset)
Definition MRMesh/MRBitSet.h:234
BitSet operator^(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:368
size_t heapBytes(const BitSet &bs)
returns the amount of memory given BitSet occupies on heap
Definition MRMesh/MRBitSet.h:219
Definition MRCameraOrientationPlugin.h:8
class MRMESH_CLASS BitSet
Definition MRMesh/MRMeshFwd.h:139
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
phmap::flat_hash_map< K, V, Hash, Eq > HashMap
Definition MRMesh/MRMeshFwd.h:528
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