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
174 void autoResizeSet( IndexType pos, size_type len, bool val = true ) { base::autoResizeSet( pos, len, val ); }
175 void autoResizeSet( IndexType pos, bool val = true ) { base::autoResizeSet( pos, val ); }
176 [[nodiscard]] bool autoResizeTestSet( IndexType pos, bool val = true ) { return base::autoResizeTestSet( pos, val ); }
177
179 template <typename M>
180 [[nodiscard]] TaggedBitSet getMapping( const M & map ) const;
181 [[nodiscard]] TaggedBitSet getMapping( const Vector<IndexType, IndexType> & map ) const
182 { return getMapping( [&map]( IndexType i ) { return map[i]; } ); }
183 [[nodiscard]] TaggedBitSet getMapping( const BMap<IndexType, IndexType> & map ) const
184 { return getMapping( [&map]( IndexType i ) { return map.b[i]; }, map.tsize ); }
185 [[nodiscard]] TaggedBitSet getMapping( const HashMap<IndexType, IndexType> & map ) const
186 { return getMapping( [&map]( IndexType i ) { return getAt( map, i ); } ); }
188 template <typename M>
189 [[nodiscard]] TaggedBitSet getMapping( const M & map, size_t resSize ) const;
190 [[nodiscard]] TaggedBitSet getMapping( const Vector<IndexType, IndexType> & map, size_t resSize ) const
191 { return getMapping( [&map]( IndexType i ) { return map[i]; }, resSize ); }
192 [[nodiscard]] TaggedBitSet getMapping( const HashMap<IndexType, IndexType> & map, size_t resSize ) const
193 { return getMapping( [&map]( IndexType i ) { return getAt( map, i ); }, resSize ); }
194
196 [[nodiscard]] IndexType backId() const { assert( !empty() ); return IndexType{ size() - 1 }; }
197
199 [[nodiscard]] static IndexType beginId() { return IndexType{ size_t( 0 ) }; }
200 [[nodiscard]] IndexType endId() const { return IndexType{ size() }; }
201};
202
204[[nodiscard]] MRMESH_API bool operator == ( const BitSet & a, const BitSet & b );
205template <typename T>
206[[nodiscard]] inline bool operator == ( const TaggedBitSet<T> & a, const TaggedBitSet<T> & b )
207 { return static_cast<const BitSet &>( a ) == static_cast<const BitSet &>( b ); }
209template <typename T, typename U>
210void operator == ( const TaggedBitSet<T> & a, const TaggedBitSet<U> & b ) = delete;
211
212template <typename T>
213[[nodiscard]] inline std::function<bool( Id<T> )> makePredicate( const TaggedBitSet<T> * bitset )
214{
215 std::function<bool( Id<T> )> res;
216 if ( bitset )
217 res = [bitset]( Id<T> id ) { return bitset->test( id ); };
218 return res;
219}
220
221template <typename T>
222[[nodiscard]] inline std::function<bool( Id<T> )> makePredicate( const TaggedBitSet<T> & bitset )
223 { return makePredicate( &bitset ); }
224
225template <typename T>
226[[nodiscard]] inline bool contains( const TaggedBitSet<T> * bitset, Id<T> id )
227{
228 return id.valid() && ( !bitset || bitset->test( id ) );
229}
230
231template <typename T>
232[[nodiscard]] inline bool contains( const TaggedBitSet<T> & bitset, Id<T> id )
233{
234 return id.valid() && bitset.test( id );
235}
236
238template <typename T>
240{
241public:
242 using IndexType = typename T::IndexType;
243
244 using iterator_category = std::forward_iterator_tag;
246 using difference_type = std::ptrdiff_t;
247 using reference = const IndexType;
248 using pointer = const IndexType *;
249
251 SetBitIteratorT() = default;
254 : bitset_( &bitset ), index_( bitset.find_first() )
255 {
256 }
258 {
259 index_ = bitset_->find_next( index_ );
260 return * this;
261 }
262 [[nodiscard]] SetBitIteratorT operator++( int )
263 {
264 SetBitIteratorT ret = *this;
265 operator++();
266 return ret;
267 }
268
269 [[nodiscard]] const T * bitset() const { return bitset_; }
270 [[nodiscard]] reference operator *() const { return index_; }
271
272private:
273 const T * bitset_ = nullptr;
274 IndexType index_ = IndexType( ~size_t( 0 ) );
275};
276
277template <typename T>
278[[nodiscard]] inline bool operator ==( const SetBitIteratorT<T> & a, const SetBitIteratorT<T> & b )
279 { return *a == *b; }
280
281template <typename T>
282[[nodiscard]] inline bool operator !=( const SetBitIteratorT<T> & a, const SetBitIteratorT<T> & b )
283 { return *a != *b; }
284
285
286[[nodiscard]] inline auto begin( const BitSet & a )
287 { return SetBitIteratorT<BitSet>(a); }
288[[nodiscard]] inline auto end( const BitSet & )
289 { return SetBitIteratorT<BitSet>(); }
290
291template <typename T>
292[[nodiscard]] inline auto begin( const TaggedBitSet<T> & a )
293 { return SetBitIteratorT<TaggedBitSet<T>>(a); }
294template <typename T>
295[[nodiscard]] inline auto end( const TaggedBitSet<T> & )
297
299template <typename T>
301{
302 Vector<int, Id<T>> res( bs.size(), -1 );
303 int n = 0;
304 for ( auto v : bs )
305 res[v] = n++;
306 return res;
307}
308
310template <typename T>
311[[nodiscard]] HashMap<Id<T>, int> makeHashMapWithSeqNums( const TaggedBitSet<T> & bs )
312{
313 HashMap<Id<T>, int> res;
314 int n = 0;
315 for ( auto v : bs )
316 res[v] = n++;
317 return res;
318}
319
320template <typename T>
321template <typename M>
322[[nodiscard]] TaggedBitSet<T> TaggedBitSet<T>::getMapping( const M & map ) const
323{
324 TaggedBitSet<T> res;
325 for ( auto b : *this )
326 if ( auto mapped = map( b ) )
327 res.autoResizeSet( mapped );
328 return res;
329}
330
331template <typename T>
332template <typename M>
333[[nodiscard]] TaggedBitSet<T> TaggedBitSet<T>::getMapping( const M & map, size_t resSize ) const
334{
335 TaggedBitSet<T> res;
336 if ( !any() )
337 return res;
338 res.resize( resSize );
339 for ( auto b : *this )
340 if ( auto mapped = map( b ) )
341 res.set( mapped );
342 return res;
343}
344
345[[nodiscard]] inline BitSet operator & ( const BitSet & a, const BitSet & b ) { BitSet res{ a }; res &= b; return res; }
346[[nodiscard]] inline BitSet operator | ( const BitSet & a, const BitSet & b ) { BitSet res{ a }; res |= b; return res; }
347[[nodiscard]] inline BitSet operator ^ ( const BitSet & a, const BitSet & b ) { BitSet res{ a }; res ^= b; return res; }
348[[nodiscard]] inline BitSet operator - ( const BitSet & a, const BitSet & b ) { BitSet res{ a }; res -= b; return res; }
349
351
352} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:68
#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:240
SetBitIteratorT operator++(int)
Definition MRMesh/MRBitSet.h:262
const IndexType * pointer
Definition MRMesh/MRBitSet.h:248
SetBitIteratorT()=default
constructs end iterator
std::forward_iterator_tag iterator_category
Definition MRMesh/MRBitSet.h:244
const T * bitset() const
Definition MRMesh/MRBitSet.h:269
IndexType value_type
Definition MRMesh/MRBitSet.h:245
const IndexType reference
intentionally not a reference
Definition MRMesh/MRBitSet.h:247
typename T::IndexType IndexType
Definition MRMesh/MRBitSet.h:242
reference operator*() const
Definition MRMesh/MRBitSet.h:270
SetBitIteratorT & operator++()
Definition MRMesh/MRBitSet.h:257
SetBitIteratorT(const T &bitset)
constructs begin iterator
Definition MRMesh/MRBitSet.h:253
std::ptrdiff_t difference_type
Definition MRMesh/MRBitSet.h:246
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:190
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
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:176
IndexType endId() const
Definition MRMesh/MRBitSet.h:200
MR_BIND_IGNORE reference operator[](IndexType pos)
Definition MRMesh/MRBitSet.h:152
TaggedBitSet & flip()
Definition MRMesh/MRBitSet.h:147
void autoResizeSet(IndexType pos, size_type len, bool val=true)
Definition MRMesh/MRBitSet.h:174
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:181
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:185
IndexType backId() const
returns the identifier of the back() element
Definition MRMesh/MRBitSet.h:196
TaggedBitSet getMapping(const BMap< IndexType, IndexType > &map) const
Definition MRMesh/MRBitSet.h:183
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:192
static IndexType beginId()
[beginId(), endId()) is the range of all bits in the set
Definition MRMesh/MRBitSet.h:199
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:175
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:348
auto begin(const BitSet &a)
Definition MRMesh/MRBitSet.h:286
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...
auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:288
BitSet operator&(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:345
std::function< bool(Id< T >)> makePredicate(const TaggedBitSet< T > *bitset)
Definition MRMesh/MRBitSet.h:213
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:300
BitSet operator|(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:346
BitSet operator^(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:347
bool contains(const TaggedBitSet< T > *bitset, Id< T > id)
Definition MRMesh/MRBitSet.h:226
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:311
bool operator!=(const SetBitIteratorT< T > &a, const SetBitIteratorT< T > &b)
Definition MRMesh/MRBitSet.h:282
class MRMESH_CLASS BitSet
Definition MRMesh/MRMeshFwd.h:124
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:482
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