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
36 // all bits after size() we silently consider as not-set
37 [[nodiscard]] bool test( IndexType n ) const { return n < size() && base::test( n ); }
38 [[nodiscard]] bool test_set( IndexType n, bool val = true ) { return ( val || n < size() ) ? base::test_set( n, val ) : false; }
39
40 BitSet & set( IndexType n, size_type len, bool val ) { base::set( n, len, val ); return * this; }
41 BitSet & set( IndexType n, bool val = true ) { base::set( n, val ); return * this; }
42 BitSet & set() { base::set(); return * this; }
43 BitSet & reset( IndexType n, size_type len ) { if ( n < size() ) base::reset( n, len ); return * this; }
44 BitSet & reset( IndexType n ) { if ( n < size() ) base::reset( n ); return * this; }
45 BitSet & reset() { base::reset(); return * this; }
46 BitSet & flip( IndexType n, size_type len ) { base::flip( n, len ); return * this; }
47 BitSet & flip( IndexType n ) { base::flip( n ); return * this; }
48 BitSet & flip() { base::flip(); return * this; }
49
51 const auto & bits() const { return m_bits; }
52
56
59 MRMESH_API BitSet & subtract( const BitSet & b, int bShiftInBlocks );
60
62 [[nodiscard]] MRMESH_API IndexType find_last() const;
63
65 [[nodiscard]] MRMESH_API size_t nthSetBit( size_t n ) const;
66
68 void resizeWithReserve( size_t newSize )
69 {
70 auto reserved = capacity();
71 if ( reserved > 0 && newSize > reserved )
72 {
73 while ( newSize > reserved )
74 reserved <<= 1;
75 reserve( reserved );
76 }
77 resize( newSize );
78 }
79
81 void autoResizeSet( size_t pos, size_type len, bool val = true )
82 {
83 if ( pos + len > size() )
84 resizeWithReserve( pos + len );
85 set( pos, len, val );
86 }
87 void autoResizeSet( size_t pos, bool val = true ) { autoResizeSet( pos, 1, val ); }
88
90 [[nodiscard]] bool autoResizeTestSet( size_t pos, bool val = true )
91 {
92 bool const b = test( pos );
93 if ( b != val )
94 autoResizeSet( pos, val );
95 return b;
96 }
97
99 [[nodiscard]] size_t heapBytes() const { return capacity() / 8; }
100
102 [[nodiscard]] IndexType backId() const { assert( !empty() ); return IndexType{ size() - 1 }; }
103
105 [[nodiscard]] static IndexType beginId() { return IndexType{ 0 }; }
106 [[nodiscard]] IndexType endId() const { return IndexType{ size() }; }
107
108 // Normally those are inherited from `boost::dynamic_bitset`, but MRBind currently chokes on it, so we provide those manually.
109 #if defined(MR_PARSING_FOR_PB11_BINDINGS) || defined(MR_COMPILING_PB11_BINDINGS)
110 std::size_t size() const { return dynamic_bitset::size(); }
111 std::size_t count() const { return dynamic_bitset::count(); }
112 void resize( std::size_t num_bits, bool value = false ) { dynamic_bitset::resize( num_bits, value ); }
113 void clear() { dynamic_bitset::clear(); }
114 void push_back( bool bit ) { dynamic_bitset::push_back( bit ); }
115 void pop_back() { dynamic_bitset::pop_back(); }
116 #endif
117
118private:
119 using base::m_highest_block;
120 using base::m_bits;
121 using base::m_num_bits;
122};
123
125template <typename T>
126class TaggedBitSet : public BitSet
127{
128 using base = BitSet;
129public:
130 using base::base;
132
134 explicit TaggedBitSet( const BitSet & src ) : BitSet( src ) {}
135
137 explicit TaggedBitSet( BitSet && src ) : BitSet( std::move( src ) ) {}
138
139 TaggedBitSet & set( IndexType n, size_type len, bool val ) { base::set( n, len, val ); return * this; }
140 TaggedBitSet & set( IndexType n, bool val = true ) { base::set( n, val ); return * this; }
141 TaggedBitSet & set() { base::set(); return * this; }
142 TaggedBitSet & reset( IndexType n, size_type len ) { base::reset( n, len ); return * this; }
143 TaggedBitSet & reset( IndexType n ) { base::reset( n ); return * this; }
144 TaggedBitSet & reset() { base::reset(); return * this; }
145 TaggedBitSet & flip( IndexType n, size_type len ) { base::flip( n, len ); return * this; }
146 TaggedBitSet & flip( IndexType n ) { base::flip( n ); return * this; }
147 TaggedBitSet & flip() { base::flip(); return * this; }
148 [[nodiscard]] bool test( IndexType n ) const { return base::test( n ); }
149 [[nodiscard]] bool test_set( IndexType n, bool val = true ) { return base::test_set( n, val ); }
150
151 // Disable for python bindings, because MRBind chokes on `boost::dynamic_bitset::reference`.
152 [[nodiscard]] MR_BIND_IGNORE reference operator[]( IndexType pos ) { return base::operator[]( pos ); }
153 [[nodiscard]] bool operator[]( IndexType pos ) const { return base::operator[]( pos ); }
154
155 [[nodiscard]] IndexType find_first() const { return IndexType( base::find_first() ); }
156 [[nodiscard]] IndexType find_next( IndexType pos ) const { return IndexType( base::find_next( pos ) ); }
157 [[nodiscard]] IndexType find_last() const { return IndexType( base::find_last() ); }
159 [[nodiscard]] IndexType nthSetBit( size_t n ) const { return IndexType( base::nthSetBit( n ) ); }
160
161 TaggedBitSet & operator &= ( const TaggedBitSet & b ) { base::operator &= ( b ); return * this; }
162 TaggedBitSet & operator |= ( const TaggedBitSet & b ) { base::operator |= ( b ); return * this; }
163 TaggedBitSet & operator ^= ( const TaggedBitSet & b ) { base::operator ^= ( b ); return * this; }
164 TaggedBitSet & operator -= ( const TaggedBitSet & b ) { base::operator -= ( b ); return * this; }
165
166 [[nodiscard]] friend TaggedBitSet operator & ( const TaggedBitSet & a, const TaggedBitSet & b ) { auto res{ a }; res &= b; return res; }
167 [[nodiscard]] friend TaggedBitSet operator | ( const TaggedBitSet & a, const TaggedBitSet & b ) { auto res{ a }; res |= b; return res; }
168 [[nodiscard]] friend TaggedBitSet operator ^ ( const TaggedBitSet & a, const TaggedBitSet & b ) { auto res{ a }; res ^= b; return res; }
169 [[nodiscard]] friend TaggedBitSet operator - ( const TaggedBitSet & a, const TaggedBitSet & b ) { auto res{ a }; res -= b; return res; }
170
172 TaggedBitSet & subtract( const TaggedBitSet & b, int bShiftInBlocks ) { base::subtract( b, bShiftInBlocks ); return * this; }
173
175 bool is_subset_of( const TaggedBitSet& a ) const { return base::is_subset_of( a ); }
176
178 bool is_proper_subset_of( const TaggedBitSet& a ) const { return base::is_proper_subset_of( a ); }
179
181 bool intersects( const TaggedBitSet & a ) const { return base::intersects( a ); }
182
183 void autoResizeSet( IndexType pos, size_type len, bool val = true ) { base::autoResizeSet( pos, len, val ); }
184 void autoResizeSet( IndexType pos, bool val = true ) { base::autoResizeSet( pos, val ); }
185 [[nodiscard]] bool autoResizeTestSet( IndexType pos, bool val = true ) { return base::autoResizeTestSet( pos, val ); }
186
188 template <typename M>
189 [[nodiscard]] TaggedBitSet getMapping( const M & map ) const;
190 [[nodiscard]] TaggedBitSet getMapping( const Vector<IndexType, IndexType> & map ) const
191 { return getMapping( [&map]( IndexType i ) { return map[i]; } ); }
192 [[nodiscard]] TaggedBitSet getMapping( const BMap<IndexType, IndexType> & map ) const
193 { return getMapping( [&map]( IndexType i ) { return map.b[i]; }, map.tsize ); }
194 [[nodiscard]] TaggedBitSet getMapping( const HashMap<IndexType, IndexType> & map ) const
195 { return getMapping( [&map]( IndexType i ) { return getAt( map, i ); } ); }
197 template <typename M>
198 [[nodiscard]] TaggedBitSet getMapping( const M & map, size_t resSize ) const;
199 [[nodiscard]] TaggedBitSet getMapping( const Vector<IndexType, IndexType> & map, size_t resSize ) const
200 { return getMapping( [&map]( IndexType i ) { return map[i]; }, resSize ); }
201 [[nodiscard]] TaggedBitSet getMapping( const HashMap<IndexType, IndexType> & map, size_t resSize ) const
202 { return getMapping( [&map]( IndexType i ) { return getAt( map, i ); }, resSize ); }
203
205 [[nodiscard]] IndexType backId() const { assert( !empty() ); return IndexType{ size() - 1 }; }
206
208 [[nodiscard]] static IndexType beginId() { return IndexType{ size_t( 0 ) }; }
209 [[nodiscard]] IndexType endId() const { return IndexType{ size() }; }
210};
211
213[[nodiscard]] MRMESH_API bool operator == ( const BitSet & a, const BitSet & b );
214template <typename T>
215[[nodiscard]] inline bool operator == ( const TaggedBitSet<T> & a, const TaggedBitSet<T> & b )
216 { return static_cast<const BitSet &>( a ) == static_cast<const BitSet &>( b ); }
218template <typename T, typename U>
219void operator == ( const TaggedBitSet<T> & a, const TaggedBitSet<U> & b ) = delete;
220
221template <typename T>
222[[nodiscard]] inline std::function<bool( Id<T> )> makePredicate( const TaggedBitSet<T> * bitset )
223{
224 std::function<bool( Id<T> )> res;
225 if ( bitset )
226 res = [bitset]( Id<T> id ) { return bitset->test( id ); };
227 return res;
228}
229
230template <typename T>
231[[nodiscard]] inline std::function<bool( Id<T> )> makePredicate( const TaggedBitSet<T> & bitset )
232 { return makePredicate( &bitset ); }
233
234template <typename T>
235[[nodiscard]] inline bool contains( const TaggedBitSet<T> * bitset, Id<T> id )
236{
237 return id.valid() && ( !bitset || bitset->test( id ) );
238}
239
240template <typename T>
241[[nodiscard]] inline bool contains( const TaggedBitSet<T> & bitset, Id<T> id )
242{
243 return id.valid() && bitset.test( id );
244}
245
247template <typename T>
248class MR_BIND_IGNORE SetBitIteratorT
249{
250public:
251 using IndexType = typename T::IndexType;
252
253 using iterator_category = std::forward_iterator_tag;
255 using difference_type = std::ptrdiff_t;
256 using reference = const IndexType;
257 using pointer = const IndexType *;
258
260 SetBitIteratorT() = default;
262 SetBitIteratorT( const T & bitset )
263 : bitset_( &bitset ), index_( bitset.find_first() )
264 {
265 }
267 {
268 index_ = bitset_->find_next( index_ );
269 return * this;
270 }
271 [[nodiscard]] SetBitIteratorT operator++( int )
272 {
273 SetBitIteratorT ret = *this;
274 operator++();
275 return ret;
276 }
277
278 [[nodiscard]] const T * bitset() const { return bitset_; }
279 [[nodiscard]] reference operator *() const { return index_; }
280
281private:
282 const T * bitset_ = nullptr;
283 IndexType index_ = IndexType( ~size_t( 0 ) );
284};
285
286template <typename T>
287[[nodiscard]] MR_BIND_IGNORE inline bool operator ==( const SetBitIteratorT<T> & a, const SetBitIteratorT<T> & b )
288 { return *a == *b; }
289
290template <typename T>
291[[nodiscard]] MR_BIND_IGNORE inline bool operator !=( const SetBitIteratorT<T> & a, const SetBitIteratorT<T> & b )
292 { return *a != *b; }
293
294
295[[nodiscard]] MR_BIND_IGNORE inline auto begin( const BitSet & a )
296 { return SetBitIteratorT<BitSet>(a); }
297[[nodiscard]] MR_BIND_IGNORE inline auto end( const BitSet & )
298 { return SetBitIteratorT<BitSet>(); }
299
300template <typename T>
301[[nodiscard]] MR_BIND_IGNORE inline auto begin( const TaggedBitSet<T> & a )
302 { return SetBitIteratorT<TaggedBitSet<T>>(a); }
303template <typename T>
304[[nodiscard]] MR_BIND_IGNORE inline auto end( const TaggedBitSet<T> & )
306
308template <typename T>
310{
311 Vector<int, Id<T>> res( bs.size(), -1 );
312 int n = 0;
313 for ( auto v : bs )
314 res[v] = n++;
315 return res;
316}
317
319template <typename T>
320[[nodiscard]] HashMap<Id<T>, int> makeHashMapWithSeqNums( const TaggedBitSet<T> & bs )
321{
322 HashMap<Id<T>, int> res;
323 int n = 0;
324 for ( auto v : bs )
325 res[v] = n++;
326 return res;
327}
328
329template <typename T>
330template <typename M>
331[[nodiscard]] TaggedBitSet<T> TaggedBitSet<T>::getMapping( const M & map ) const
332{
333 TaggedBitSet<T> res;
334 for ( auto b : *this )
335 if ( auto mapped = map( b ) )
336 res.autoResizeSet( mapped );
337 return res;
338}
339
340template <typename T>
341template <typename M>
342[[nodiscard]] TaggedBitSet<T> TaggedBitSet<T>::getMapping( const M & map, size_t resSize ) const
343{
344 TaggedBitSet<T> res;
345 if ( !any() )
346 return res;
347 res.resize( resSize );
348 for ( auto b : *this )
349 if ( auto mapped = map( b ) )
350 res.set( mapped );
351 return res;
352}
353
354[[nodiscard]] inline BitSet operator & ( const BitSet & a, const BitSet & b ) { BitSet res{ a }; res &= b; return res; }
355[[nodiscard]] inline BitSet operator | ( const BitSet & a, const BitSet & b ) { BitSet res{ a }; res |= b; return res; }
356[[nodiscard]] inline BitSet operator ^ ( const BitSet & a, const BitSet & b ) { BitSet res{ a }; res ^= b; return res; }
357[[nodiscard]] inline BitSet operator - ( const BitSet & a, const BitSet & b ) { BitSet res{ a }; res -= b; return res; }
358
360
361} // 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:106
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:105
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:45
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 & set(IndexType n, size_type len, bool val)
Definition MRMesh/MRBitSet.h:40
BitSet & set()
Definition MRMesh/MRBitSet.h:42
void autoResizeSet(size_t pos, bool val=true)
Definition MRMesh/MRBitSet.h:87
BitSet & reset(IndexType n, size_type len)
Definition MRMesh/MRBitSet.h:43
BitSet & set(IndexType n, bool val=true)
Definition MRMesh/MRBitSet.h:41
bool autoResizeTestSet(size_t pos, bool val=true)
same as autoResizeSet and returns previous value of pos-bit
Definition MRMesh/MRBitSet.h:90
bool test_set(IndexType n, bool val=true)
Definition MRMesh/MRBitSet.h:38
BitSet & flip(IndexType n, size_type len)
Definition MRMesh/MRBitSet.h:46
BitSet & reset(IndexType n)
Definition MRMesh/MRBitSet.h:44
bool test(IndexType n) const
Definition MRMesh/MRBitSet.h:37
BitSet & flip()
Definition MRMesh/MRBitSet.h:48
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:81
IndexType backId() const
returns the identifier of the back() element
Definition MRMesh/MRBitSet.h:102
void resizeWithReserve(size_t newSize)
doubles reserved memory until resize(newSize) can be done without reallocation
Definition MRMesh/MRBitSet.h:68
const auto & bits() const
read-only access to all bits stored as a vector of uint64 blocks
Definition MRMesh/MRBitSet.h:51
size_t heapBytes() const
returns the amount of memory this object occupies on heap
Definition MRMesh/MRBitSet.h:99
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:47
Definition MRMesh/MRId.h:13
iterator to enumerate all indices with set bits in BitSet class or its derivatives
Definition MRMesh/MRBitSet.h:249
SetBitIteratorT operator++(int)
Definition MRMesh/MRBitSet.h:271
const IndexType * pointer
Definition MRMesh/MRBitSet.h:257
SetBitIteratorT()=default
constructs end iterator
std::forward_iterator_tag iterator_category
Definition MRMesh/MRBitSet.h:253
const T * bitset() const
Definition MRMesh/MRBitSet.h:278
IndexType value_type
Definition MRMesh/MRBitSet.h:254
const IndexType reference
intentionally not a reference
Definition MRMesh/MRBitSet.h:256
typename T::IndexType IndexType
Definition MRMesh/MRBitSet.h:251
SetBitIteratorT & operator++()
Definition MRMesh/MRBitSet.h:266
SetBitIteratorT(const T &bitset)
constructs begin iterator
Definition MRMesh/MRBitSet.h:262
std::ptrdiff_t difference_type
Definition MRMesh/MRBitSet.h:255
container of bits representing specific indices (faces, verts or edges)
Definition MRMesh/MRBitSet.h:127
TaggedBitSet & operator^=(const TaggedBitSet &b)
Definition MRMesh/MRBitSet.h:163
TaggedBitSet getMapping(const Vector< IndexType, IndexType > &map, size_t resSize) const
Definition MRMesh/MRBitSet.h:199
bool test_set(IndexType n, bool val=true)
Definition MRMesh/MRBitSet.h:149
TaggedBitSet(BitSet &&src)
moves all bits from another BitSet (or a descending class, e.g. TaggedBitSet)
Definition MRMesh/MRBitSet.h:137
TaggedBitSet & operator-=(const TaggedBitSet &b)
Definition MRMesh/MRBitSet.h:164
bool test(IndexType n) const
Definition MRMesh/MRBitSet.h:148
bool is_proper_subset_of(const TaggedBitSet &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:178
TaggedBitSet & operator|=(const TaggedBitSet &b)
Definition MRMesh/MRBitSet.h:162
TaggedBitSet & reset(IndexType n, size_type len)
Definition MRMesh/MRBitSet.h:142
bool autoResizeTestSet(IndexType pos, bool val=true)
Definition MRMesh/MRBitSet.h:185
IndexType endId() const
Definition MRMesh/MRBitSet.h:209
MR_BIND_IGNORE reference operator[](IndexType pos)
Definition MRMesh/MRBitSet.h:152
bool intersects(const TaggedBitSet &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:181
TaggedBitSet & flip()
Definition MRMesh/MRBitSet.h:147
void autoResizeSet(IndexType pos, size_type len, bool val=true)
Definition MRMesh/MRBitSet.h:183
bool is_subset_of(const TaggedBitSet &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:175
IndexType find_next(IndexType pos) const
Definition MRMesh/MRBitSet.h:156
TaggedBitSet & reset(IndexType n)
Definition MRMesh/MRBitSet.h:143
IndexType find_first() const
Definition MRMesh/MRBitSet.h:155
TaggedBitSet & set(IndexType n, size_type len, bool val)
Definition MRMesh/MRBitSet.h:139
IndexType find_last() const
Definition MRMesh/MRBitSet.h:157
friend TaggedBitSet operator-(const TaggedBitSet &a, const TaggedBitSet &b)
Definition MRMesh/MRBitSet.h:169
TaggedBitSet & subtract(const TaggedBitSet &b, int bShiftInBlocks)
subtracts b from this, considering that bits in b are shifted right on bShiftInBlocks*bits_per_block
Definition MRMesh/MRBitSet.h:172
TaggedBitSet & flip(IndexType n)
Definition MRMesh/MRBitSet.h:146
TaggedBitSet getMapping(const M &map) const
constructs another bit set from this where every set bit index is transformed using given map
TaggedBitSet getMapping(const Vector< IndexType, IndexType > &map) const
Definition MRMesh/MRBitSet.h:190
TaggedBitSet & operator&=(const TaggedBitSet &b)
Definition MRMesh/MRBitSet.h:161
TaggedBitSet & set()
Definition MRMesh/MRBitSet.h:141
TaggedBitSet(const BitSet &src)
copies all bits from another BitSet (or a descending class, e.g. TaggedBitSet)
Definition MRMesh/MRBitSet.h:134
TaggedBitSet getMapping(const HashMap< IndexType, IndexType > &map) const
Definition MRMesh/MRBitSet.h:194
IndexType backId() const
returns the identifier of the back() element
Definition MRMesh/MRBitSet.h:205
TaggedBitSet getMapping(const BMap< IndexType, IndexType > &map) const
Definition MRMesh/MRBitSet.h:192
friend TaggedBitSet operator^(const TaggedBitSet &a, const TaggedBitSet &b)
Definition MRMesh/MRBitSet.h:168
bool operator[](IndexType pos) const
Definition MRMesh/MRBitSet.h:153
TaggedBitSet getMapping(const HashMap< IndexType, IndexType > &map, size_t resSize) const
Definition MRMesh/MRBitSet.h:201
static IndexType beginId()
[beginId(), endId()) is the range of all bits in the set
Definition MRMesh/MRBitSet.h:208
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:159
void autoResizeSet(IndexType pos, bool val=true)
Definition MRMesh/MRBitSet.h:184
TaggedBitSet & reset()
Definition MRMesh/MRBitSet.h:144
TaggedBitSet getMapping(const M &map, size_t resSize) const
this is a faster version if the result size is known beforehand
friend TaggedBitSet operator&(const TaggedBitSet &a, const TaggedBitSet &b)
Definition MRMesh/MRBitSet.h:166
friend TaggedBitSet operator|(const TaggedBitSet &a, const TaggedBitSet &b)
Definition MRMesh/MRBitSet.h:167
Id< T > IndexType
Definition MRMesh/MRBitSet.h:131
TaggedBitSet & set(IndexType n, bool val=true)
Definition MRMesh/MRBitSet.h:140
TaggedBitSet & flip(IndexType n, size_type len)
Definition MRMesh/MRBitSet.h:145
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:20
BitSet operator-(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:357
MR_BIND_IGNORE auto begin(const BitSet &a)
Definition MRMesh/MRBitSet.h:295
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:354
std::function< bool(Id< T >)> makePredicate(const TaggedBitSet< T > *bitset)
Definition MRMesh/MRBitSet.h:222
Vector< int, Id< T > > makeVectorWithSeqNums(const TaggedBitSet< T > &bs)
creates a Vector where for each set bit of input bitset its sequential number starting from 0 is retu...
Definition MRMesh/MRBitSet.h:309
BitSet operator|(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:355
MR_BIND_IGNORE bool operator!=(const SetBitIteratorT< T > &a, const SetBitIteratorT< T > &b)
Definition MRMesh/MRBitSet.h:291
MR_BIND_IGNORE auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:297
BitSet operator^(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:356
bool contains(const TaggedBitSet< T > *bitset, Id< T > id)
Definition MRMesh/MRBitSet.h:235
HashMap< Id< T >, int > makeHashMapWithSeqNums(const TaggedBitSet< T > &bs)
creates a HashMap where for each set bit of input bitset its sequential number starting from 0 is ret...
Definition MRMesh/MRBitSet.h:320
class MRMESH_CLASS BitSet
Definition MRMesh/MRMeshFwd.h:135
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:32
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
SetBitIteratorT< BitSet >(FaceSetBitIterator, SetBitIteratorT< FaceBitSet >)(VertSetBitIterator
phmap::flat_hash_map< K, V, Hash, Eq > HashMap
Definition MRMesh/MRMeshFwd.h:505
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