Loading...
Searching...
No Matches
bitSet.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2018-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::bitSet
28
29Description
30 A bitSet stores bits (elements with only two states) in packed internal
31 format and supports a variety of bit-set operations.
32 Its behaviour is largely list-like, with some HashSet features.
33
34SourceFiles
35 bitSetI.H
36 bitSet.C
37 bitSetIO.C
38 bitSet.txx
39
40See also
41 Foam::BitOps
42 Foam::PackedList
43
44\*---------------------------------------------------------------------------*/
45
46#ifndef Foam_bitSet_H
47#define Foam_bitSet_H
48
49#include "PackedList.H"
50
51// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52
53namespace Foam
54{
55
56// Forward Declarations
57class bitSet;
59/*---------------------------------------------------------------------------*\
60 Class bitSet Declaration
61\*---------------------------------------------------------------------------*/
62
63class bitSet
64:
65 public PackedList<1>
66{
67protected:
68
69 // Logic/Set Operations
70
71 //- The set difference
72 // \code
73 // A = (A - B)
74 // A = (A & !B)
75 // A = (A & ~B)
76 // \endcode
77 // A and B can have different sizes.
78 // Never changes the original set size.
79 // Non-overlapping parts are considered \em off.
80 bitSet& minusEq(const bitSet& other);
81
82 //- The set logical AND
83 // \code
84 // A = (A & B)
85 //
86 // \endcode
87 // A and B can have different sizes.
88 // Never changes the original set size.
89 // Non-overlapping parts are considered \em off.
90 bitSet& andEq(const bitSet& other);
91
92 //- The set logical OR
93 // \code
94 // A = (A | B)
95 // \endcode
96 // A and B can have different sizes
97 //
98 // The size grows to accommodate new \em on bits.
99 bitSet& orEq(const bitSet& other);
100
101 //- The set logical XOR
102 // \code
103 // A = (A ^ B)
104 // \endcode
105 // A and B can have different sizes.
106 //
107 // The size grows to accommodate new \em on bits.
108 bitSet& xorEq(const bitSet& other);
109
110
111public:
112
113 //- A bitSet acts like a packed boolList
114 typedef bool value_type;
115
116
117 // Forward Declarations
118
119 class reference;
120 class const_iterator;
121 typedef unsigned int const_reference;
122
124 // Static Member Functions
125
126 //- Return a null bitSet (reference to a nullObject).
127 static const bitSet& null() noexcept
128 {
129 return NullObjectRef<bitSet>();
131
132
133 //- Declare type-name (with debug switch)
134 ClassName("bitSet");
135
136
137 // Constructors
139 //- Default construct an empty, zero-sized bitSet
140 inline constexpr bitSet() noexcept;
141
142 //- Construct from Istream
143 explicit bitSet(Istream& is);
144
145 //- Construct with given size, with all bits set to 0
146 inline explicit bitSet(const label n);
148 //- Construct with given size and value for all elements
149 inline bitSet(const label n, const bool val);
150
151 //- Copy construct
152 inline bitSet(const bitSet& bitset);
153
154 //- Move construct
155 inline bitSet(bitSet&& bitset);
156
157 //- Construct a new bitSet by extracting the specified (unique)
158 //- locations of an existing bitSet.
159 bitSet(const bitSet& bitset, const labelUList& addr);
160
161 //- Construct a new set by extracting the specified (unique)
162 //- locations of an existing bitSet.
163 template<class Addr>
164 bitSet
165 (
166 const bitSet& bitset,
167 const IndirectListBase<label, Addr>& addr
168 );
169
170 //- Construct a new bitSet by extracting the specified range
171 //- locations of an existing bitSet.
172 bitSet(const bitSet& bitset, const labelRange& range);
173
174 //- Construct from a list of bools
175 inline explicit bitSet(const UList<bool>& bools);
176
177 //- Construct with given pre-size (filled with 0),
178 //- subsequently add specified locations as 1,
179 //- auto-vivify entries if needed.
180 explicit bitSet(const label n, const labelRange& range);
181
182 //- Construct with given pre-size (filled with 0),
183 //- subsequently add specified locations as 1,
184 //- auto-vivify entries if needed.
185 inline bitSet(const label n, const labelUList& locations);
186
187 //- Construct with given pre-size (filled with 0),
188 //- subsequently add specified locations as 1,
189 //- auto-vivify entries if needed.
190 template<class Addr>
191 bitSet
192 (
193 const label n,
194 const IndirectListBase<label, Addr>& locations
195 );
196
197 //- Construct with given pre-size (filled with 0),
198 //- subsequently add specified locations as 1,
199 //- auto-vivify entries if needed.
200 template<unsigned N>
201 bitSet(const label n, const FixedList<label, N>& locations);
202
203 //- Construct with given pre-size (filled with 0),
204 //- subsequently add specified locations as 1,
205 //- auto-vivify entries if needed.
206 inline bitSet(const label n, std::initializer_list<label> locations);
207
208 //- Construct with automatic sizing (filled with 0),
209 //- and set the specified locations as 1.
210 explicit bitSet(const labelRange& range);
211
212 //- Construct with automatic sizing (filled with 0),
213 //- and set the specified locations as 1.
214 inline explicit bitSet(const labelUList& locations);
215
216 //- Construct with automatic sizing (filled with 0),
217 //- and set the specified locations as 1.
218 template<class Addr>
219 inline explicit bitSet(const IndirectListBase<label, Addr>& locations);
220
221 //- Construct with automatic sizing (filled with 0),
222 //- and set the specified locations as 1.
223 template<unsigned N>
224 explicit bitSet(const FixedList<label, N>& locations);
225
226 //- Clone
227 inline autoPtr<bitSet> clone() const;
228
229
230 // Member Functions
231
232 // Query
233
234 //- True if all bits in this bitset are set or if the set is \b empty.
235 // Returning true for an empty set may not seem intuitive, but
236 // conforms with boost definitions and std::all_of behaviour.
237 // \note Method name compatibility with boost::dynamic_bitset
238 inline bool all() const;
239
240 //- True if any bits in this bitset are set.
241 // \note Method name compatibility with boost::dynamic_bitset
242 inline bool any() const;
243
244 //- True if no bits in this bitset are set.
245 // \note Method name compatibility with boost::dynamic_bitset
246 inline bool none() const;
247
248 //- Count number of bits set.
249 // \param on can be set to false to count the number of unset bits
250 // instead.
251 // \note Method name compatibility with boost::dynamic_bitset
252 inline unsigned int count(const bool on=true) const;
253
254 //- True if any bits in the other bitset intersect (are the same).
255 //
256 // \note Method name compatibility with boost::dynamic_bitset
257 bool intersects(const bitSet& other) const;
258
259 //- Test for \em True value at specified position,
260 //- never auto-vivify entries.
261 //
262 // \note Method name compatibility with std::bitset
263 bool test(const label pos) const { return this->get(pos); }
264
265 //- Test for \em True value at specified position,
266 //- never auto-vivify entries.
267 //
268 // \note Method name compatibility with HashSet
269 bool contains(const label pos) const { return this->get(pos); }
270
271 //- Locate the first bit that is set.
272 // \return the location or -1 if there are no bits set.
273 //
274 // \note Method name compatibility with boost::dynamic_bitset
275 inline label find_first() const;
276
277 //- Locate the first bit that is unset.
278 // \return the location or -1 if the set is empty or all bits are on.
279 //
280 // \note Provided for symmetry with find_first()
281 inline label find_first_not() const;
282
283 //- Locate the last bit set.
284 // \return the location or -1 if there are no bits set.
285 //
286 // \note Provided for symmetry with find_first()
287 inline label find_last() const;
288
289 //- Locate the next bit set, starting one beyond the specified position
290 // \return the location or -1 if there are no further bits set.
291 //
292 // \note Method name compatibility with boost::dynamic_bitset
293 inline label find_next(label pos) const;
294
295 //- The indices of the \a on bits as a sorted labelList.
296 //
297 // \note Method name compatibility with HashSet
298 labelList toc() const;
299
300 //- The indices of the \a on bits as a sorted labelList.
301 // This is identical to toc(), which is always sorted.
302 //
303 // \note Method name compatibility with HashSet
304 inline labelList sortedToc() const;
305
306 //- Return the bitset values as a boolList.
307 // When the output is a bool, this is more efficient than unpack()
308 List<bool> values() const;
309
310
311 // Assignment
312
313 //- Assign all entries to the given value.
314 inline void fill(const bool val);
315
316 //- Copy assign all entries from a list of bools.
317 void assign(const UList<bool>& bools);
318
319
320 // Setting single or multiple values
321
322 //- Assign a single index/value
323 using PackedList<1>::set;
324
325 //- Set specified bits from another bitset.
326 // The current set size may grow to accommodate any new bits
327 // (auto-vivifies).
328 inline void set(const bitSet& bitset);
329
330 //- Set the specified range of bits
331 // The current set size may grow to accommodate any new bits
332 // (auto-vivifies).
333 // \note this operation is generally more efficient than calling
334 // set(pos) on individual bits.
335 void set(const labelRange& range);
336
337 //- Test for \em True value at specified position
338 //- and change the value at that position.
339 // Does auto-vivify for non-existent, non-zero entries.
340 //
341 // \note Method name compatibility with std::bitset
342 bool test_set(const label i, const bool val = true);
344
345 // Unsetting single or multiple values
346
347 //- Unset a single index
348 using PackedList<1>::unset;
349
350 //- Unset (subtract) the bits specified in the other bitset, which is
351 //- a set difference corresponds to the logical operation
352 // \code
353 // A = (A & !B)
354 // \endcode
355 // The result is comparable to 'operator-='
356 // \endcode
357 //
358 // A and B can have different sizes.
359 // Does not change the original set size.
360 inline bitSet& unset(const bitSet& other);
361
362 //- Unset the specified range of bits specified, never auto-vivifies.
363 // \note this operation can be more efficient than calling
364 // unset(pos) on individual bits.
365 void unset(const labelRange& range);
366
367
368 // Edit
369
370 //- Invert all bits in the addressable region
371 inline void flip();
372
373 //- Invert bit at the specified position.
374 // A no-op if the position is out-of-range
375 inline void flip(const label pos);
376
377 //- Resize to include the last \em on bit only.
378 // Functionally identical to resize(find_last()+1)
379 inline void resize_last();
380
381 //- Swap contents
382 inline void swap(bitSet& bitset);
383
384 //- Transfer the contents of the argument list into this list
385 //- and annul the argument list.
386 inline void transfer(bitSet& bitset);
387
388
389 // Convenience methods
390
391 //- Ensure the addressable range does not exceed maxSize.
392 // Either decreases the size of the bitSet or is a no-op.
393 //
394 // \code
395 // pointField& pts = mesh.points();
396 // bitset.bound(pts.size());
397 //
398 // for (const label pointi : bitset)
399 // {
400 // pts[pointi] ...
401 // }
402 // \endcode
403 inline bitSet& bound(const label maxSize);
404
405 //- Ensure the addressable range does not exceed that of other.
406 // Either decreases the size of the bitSet or is a no-op.
407 inline bitSet& bound(const bitSet& other);
408
409 //- Ensure that minSize is covered by the bitSet.
410 // Either increases the size of the bitSet or is a no-op.
411 inline bitSet& extend(const label minSize);
412
413 //- Ensure the bitset is addressable throughout the range of other.
414 // Either increases the size of the bitSet or is a no-op.
415 inline bitSet& extend(const bitSet& other);
416
417 //- Set the locations listed by the iterator range,
418 //- auto-vivify entries if needed.
419 //
420 // \return number of locations changed
421 template<class InputIter>
422 label setMany(InputIter first, InputIter last);
423
424 //- Set the listed locations to 1.
425 // Does auto-vivify for non-existent entries.
426 //
427 // \return number of locations changed
428 inline label set(const labelUList& locations);
429
430 //- Set the listed locations to 1.
431 // Does auto-vivify for non-existent entries.
432 //
433 // \return number of locations changed
434 template<class Addr>
435 inline label set(const IndirectListBase<label, Addr>& locations);
436
437 //- Set the listed locations to 1.
438 // Does auto-vivify for non-existent entries.
439 //
440 // \return number of locations changed
441 template<unsigned N>
442 label set(const FixedList<label, N>& locations);
443
444 //- Unset the locations listed by the iterator range,
445 //- never auto-vivify entries.
446 //
447 // \return number of locations changed
448 template<class InputIter>
449 label unset(InputIter first, InputIter last);
450
451 //- Unset the listed locations, never auto-vivifies.
452 //
453 // \return number of locations changed
454 inline label unset(const labelUList& locations);
455
456 //- Unset the listed locations, never auto-vivifies.
457 //
458 // \return number of locations changed
459 template<class Addr>
460 inline label unset(const IndirectListBase<label, Addr>& locations);
461
462 //- Unset the listed locations, never auto-vivifies.
463 //
464 // \return number of locations changed
465 template<unsigned N>
466 label unset(const FixedList<label, N>& locations);
467
468
469 // Access helpers
470
471 //- A reference supporting read/write access to an entry
472 class reference
473 :
474 public PackedList<1>::reference
475 {
476 protected:
477
478 friend class bitSet; // Access for parent
479 void operator&() = delete; // Refuse to provide its address
480
481 //- Construct by taking reference of block from within
482 //- the list and the specified index.
483 inline reference(bitSet* parent, const label index);
484
485 public:
486
487 //- Copy construct
488 reference(const reference&) noexcept = default;
489
490 //- Move construct
491 reference(reference&&) noexcept = default;
492
493 //- Flip the bit at the position, no range-checking
494 inline void flip();
495
496 //- Value assignment
497 inline void operator=(const reference& other);
498
499 //- Value assignment
500 inline void operator=(const unsigned int val);
501
502 //- Conversion operator
503 inline operator unsigned int () const;
504 };
505
506
507 // Iteration
508
509 //- A const_iterator for iterating across \a on values
510 class const_iterator
511 {
512 friend class bitSet;
513
514 //- The parent being iterated
515 const bitSet* set_;
516
517 //- Global position of the current \a on bit
518 label pos_;
519
520 //- Default construct - an end iterator
521 inline const_iterator() noexcept;
522
523 //- Construct begin iterator
524 inline const_iterator(const bitSet* bitset);
525
526 //- Construct iterator, starting at or beyond the given position
527 inline const_iterator(const bitSet* bitset, label pos);
528
529 public:
530
531 //- Return the current \a on position
532 inline label operator*() const noexcept;
533
534 //- Move to the next \a on position
535 inline const_iterator& operator++();
536
537 inline bool operator==(const const_iterator& iter) const noexcept;
538 inline bool operator!=(const const_iterator& iter) const noexcept;
539 };
540
541
542 //- Iterator set to the position of the first \a on bit
543 inline const_iterator begin() const;
544
545 //- Iterator set to the position of the first \a on bit
546 inline const_iterator cbegin() const;
547
548 //- Iterator set to the position of the first \a on bit that occurs
549 //- at or beyond the given position
550 inline const_iterator begin(label pos) const;
551
552 //- Iterator set to the position of the first \a on bit that occurs
553 //- at or beyond the given position
554 inline const_iterator cbegin(label pos) const;
555
556 //- Iterator beyond the end of the bitSet
557 inline const_iterator end() const noexcept;
558
559 //- Iterator beyond the end of the bitSet
560 inline const_iterator cend() const noexcept;
561
562
563 // Member Operators
564
565 //- Test value at specified position, same as test()
566 // Enables use as a predicate
567 inline bool operator()(const label pos) const;
568
569 //- Identical to get() - get value at index.
570 // Never auto-vivify entries.
571 inline unsigned int operator[](const label i) const;
572
573 //- Non-const access to value at index.
574 // Fatal for out-of-range indices
575 inline reference operator[](const label i);
576
577 //- Copy assignment
578 inline bitSet& operator=(const bitSet& bitset);
579
580 //- Move assignment
581 inline bitSet& operator=(bitSet&& bitset);
582
583 //- Assign all entries to the given value. fill()
584 inline bitSet& operator=(const bool val);
585
586 //- Bitwise-AND all the bits in other with the bits in this bitset.
587 // The operands may have dissimilar sizes,
588 // never changes the original set size.
589 // Non-overlapping elements are considered \em off.
590 inline bitSet& operator&=(const bitSet& other);
591
592 //- Bitwise-OR operator - similar to the set() method.
593 // The operands may have dissimilar sizes,
594 // the set grows to accommodate new \em on bits.
595 inline bitSet& operator|=(const bitSet& other);
597 //- Bitwise-XOR operator - retains unique entries.
598 // The operands may have dissimilar sizes,
599 // the set grows to accommodate new \em on bits.
600 inline bitSet& operator^=(const bitSet& other);
601
602 //- Remove entries from this list - identical to the unset() method.
603 // The operands may have dissimilar sizes,
604 // never changes the original set size.
605 inline bitSet& operator-=(const bitSet& other);
607
608 // Reading/writing
609
610
611 //- Read contents in "compact" format, which is the listing
612 //- of the 'on' bits (toc)
613 // This function mostly useful for relatively sparse sets.
614 // \note currently ASCII only.
616
617 //- Write contents in "compact" format, which is the listing
618 //- of the 'on' bits (toc), with line-breaks in ASCII guided
619 //- by shortLen parameter ('0' suppresses line-breaks entirely).
620 // This function mostly useful for relatively sparse sets.
621 // \note currently ASCII only.
622 Ostream& writeListToc(Ostream& os, label shortLen=0) const;
624 //- Return info proxy,
625 //- used to print information to a stream
627 {
628 return *this;
629 }
630
631
632 // Parallel Operations
633
634 //- Broadcast the contents
635 void broadcast
636 (
638 int communicator = -1,
640 bool syncSizes = true
641 );
642
643 //- Broadcast the contents using the specified communicator/root
644 void broadcast
645 (
647 std::pair<int,int> communicator_root,
649 bool syncSizes = true
650 );
651
652 //- Inplace \c bit_and parallel reduction
653 void reduceAnd
654 (
656 int communicator = -1,
658 bool syncSizes = true
659 );
661 //- Inplace \c bit_or parallel reduction
662 void reduceOr
663 (
665 int communicator = -1,
667 bool syncSizes = true
668 );
669
670 //- Gather individual values into bitSet locations.
671 // On master, the resulting bitSet has size == nProcs,
672 // otherwise zero length.
673 // \n
674 // For \b non-parallel :
675 // the length of the returned set is 1 with localValue.
676 static bitSet gatherValues
677 (
679 bool localValue,
681 int communicator = -1
682 );
683
684 //- Allgather individual values into bitSet locations.
685 // The resulting bitSet has size nProcs, identical on all ranks.
686 // Behaves like Pstream::allGatherValues() but returning a bitSet.
687 static bitSet allGather
688 (
690 bool localValue,
692 int communicator = -1
693 );
695
696 // Housekeeping
697
698 //- Same as contains()
699 bool found(const label pos) const { return this->contains(pos); }
700
701 //- Deprecated(2020-11) use fill()
702 // \deprecated(2020-11) use fill()
703 void assign(const unsigned int val) { this->fill(val); }
704};
705
706
707// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
708
709//- Hashing for bitSet data
710template<> struct Hash<bitSet> : bitSet::hasher {};
711
712
713// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
714
715//- Write bitset to Ostream with 40 items per line.
716Ostream& operator<<(Ostream& os, const bitSet& bitset);
717
718//- Output bitset information
719Ostream& operator<<(Ostream& os, const InfoProxy<bitSet>& iproxy);
720
721
722//- Bitset complement, returns a copy of the bitset with all its bits flipped
723inline bitSet operator~(const bitSet& bitset);
724
725//- Bitwise-AND of two bitsets.
726// See bitSet::operator&= for more details.
727inline bitSet operator&(const bitSet& a, const bitSet& b);
728
729//- Bitwise-OR of two bitsets
730// See bitSet::operator|= for more details.
731inline bitSet operator|(const bitSet& a, const bitSet& b);
732
733//- Bitwise-XOR of two bitsets to form a unique bit-set
734// See bitSet::operator^= for more details.
735inline bitSet operator^(const bitSet& a, const bitSet& b);
736
737//- Bitwise difference (subset) of two bitsets to form a unique bit-set
738// See bitSet::operator-= for more details.
739inline bitSet operator-(const bitSet& a, const bitSet& b);
740
741
742// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
743
744} // End namespace Foam
745
746// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
747
748#include "bitSetI.H"
749
750// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
751
752#ifdef NoRepository
753 #include "bitSet.txx"
754#endif
755
756// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
757
758#endif
759
760// ************************************************************************* //
scalar range
bool found
label n
A 1D vector of objects of type <T> with a fixed length <N>.
Definition FixedList.H:73
Base for lists with indirect addressing, templated on the list contents type and the addressing type....
A helper class for outputting values to Ostream.
Definition InfoProxy.H:49
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
Definition PackedList.H:146
friend Ostream & operator<<(Ostream &os, const InfoProxy< PackedList< Width > > &info)
unsigned int get(const label i) const
constexpr PackedList() noexcept
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A const_iterator for iterating across on values.
Definition bitSet.H:695
A reference supporting read/write access to an entry.
Definition bitSet.H:643
reference(bitSet *parent, const label index)
Construct by taking reference of block from within the list and the specified index.
Definition bitSetI.H:125
void flip()
Flip the bit at the position, no range-checking.
Definition bitSetI.H:134
void operator&()=delete
reference(reference &&) noexcept=default
Move construct.
reference(const reference &) noexcept=default
Copy construct.
friend class bitSet
Definition bitSet.H:646
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
unsigned int count(const bool on=true) const
Count number of bits set.
Definition bitSetI.H:420
void fill(const bool val)
Assign all entries to the given value.
Definition bitSetI.H:474
void reduceAnd(int communicator=-1, bool syncSizes=true)
Inplace bit_and parallel reduction.
Definition bitSet.C:656
const_iterator cbegin() const
Iterator set to the position of the first on bit.
Definition bitSetI.H:230
unsigned int const_reference
Definition bitSet.H:130
void flip()
Invert all bits in the addressable region.
Definition bitSetI.H:546
label find_last() const
Locate the last bit set.
Definition bitSetI.H:321
labelList sortedToc() const
The indices of the on bits as a sorted labelList.
Definition bitSetI.H:441
ClassName("bitSet")
Declare type-name (with debug switch).
static bitSet gatherValues(bool localValue, int communicator=-1)
Gather individual values into bitSet locations.
Definition bitSet.C:755
void broadcast(int communicator=-1, bool syncSizes=true)
Broadcast the contents.
Definition bitSet.C:642
const_iterator end() const noexcept
Iterator beyond the end of the bitSet.
Definition bitSetI.H:248
label set(const IndirectListBase< label, Addr > &locations)
Set the listed locations to 1.
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition bitSetI.H:502
bool contains(const label pos) const
Test for True value at specified position, never auto-vivify entries.
Definition bitSet.H:343
void transfer(bitSet &bitset)
Transfer the contents of the argument list into this list and annul the argument list.
Definition bitSetI.H:468
bool none() const
True if no bits in this bitset are set.
Definition bitSetI.H:414
autoPtr< bitSet > clone() const
Clone.
Definition bitSetI.H:116
constexpr bitSet() noexcept
Default construct an empty, zero-sized bitSet.
Definition bitSetI.H:23
bool test(const label pos) const
Test for True value at specified position, never auto-vivify entries.
Definition bitSet.H:334
bitSet & bound(const label maxSize)
Ensure the addressable range does not exceed maxSize.
Definition bitSetI.H:570
void assign(const unsigned int val)
Deprecated(2020-11) use fill().
Definition bitSet.H:967
label find_first_not() const
Locate the first bit that is unset.
Definition bitSetI.H:289
Istream & readListToc(Istream &is)
Read contents in "compact" format, which is the listing of the 'on' bits (toc).
Definition bitSetIO.C:132
bitSet & xorEq(const bitSet &other)
The set logical XOR.
Definition bitSet.C:171
label unset(InputIter first, InputIter last)
Unset the locations listed by the iterator range, never auto-vivify entries.
bool test_set(const label i, const bool val=true)
Test for True value at specified position and change the value at that position.
Definition bitSetI.H:494
bool all() const
True if all bits in this bitset are set or if the set is empty.
Definition bitSetI.H:401
labelList toc() const
The indices of the on bits as a sorted labelList.
Definition bitSet.C:476
const_iterator begin() const
Iterator set to the position of the first on bit.
Definition bitSetI.H:224
void reduceOr(int communicator=-1, bool syncSizes=true)
Inplace bit_or parallel reduction.
Definition bitSet.C:705
void assign(const UList< bool > &bools)
Copy assign all entries from a list of bools.
Definition bitSet.C:271
label unset(const FixedList< label, N > &locations)
Unset the listed locations, never auto-vivifies.
InfoProxy< bitSet > info() const noexcept
Return info proxy, used to print information to a stream.
Definition bitSet.H:871
void resize_last()
Resize to include the last on bit only.
Definition bitSetI.H:447
bool found(const label pos) const
Same as contains().
Definition bitSet.H:960
List< bool > values() const
Return the bitset values as a boolList.
Definition bitSet.C:515
bitSet & andEq(const bitSet &other)
The set logical AND.
Definition bitSet.C:74
bitSet & orEq(const bitSet &other)
The set logical OR.
Definition bitSet.C:126
static bitSet allGather(bool localValue, int communicator=-1)
Allgather individual values into bitSet locations.
Definition bitSet.C:800
bitSet & unset(const bitSet &other)
Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the...
Definition bitSetI.H:540
void swap(bitSet &bitset)
Swap contents.
Definition bitSetI.H:462
Ostream & writeListToc(Ostream &os, label shortLen=0) const
Write contents in "compact" format, which is the listing of the 'on' bits (toc), with line-breaks in ...
Definition bitSetIO.C:36
label set(const FixedList< label, N > &locations)
Set the listed locations to 1.
label setMany(InputIter first, InputIter last)
Set the locations listed by the iterator range, auto-vivify entries if needed.
const_iterator cend() const noexcept
Iterator beyond the end of the bitSet.
Definition bitSetI.H:254
bool intersects(const bitSet &other) const
True if any bits in the other bitset intersect (are the same).
Definition bitSet.C:296
label find_next(label pos) const
Locate the next bit set, starting one beyond the specified position.
Definition bitSetI.H:347
bool value_type
A bitSet acts like a packed boolList.
Definition bitSet.H:123
bitSet & minusEq(const bitSet &other)
The set difference.
Definition bitSet.C:39
bool any() const
True if any bits in this bitset are set.
Definition bitSetI.H:408
static const bitSet & null() noexcept
Return a null bitSet (reference to a nullObject).
Definition bitSet.H:138
bitSet & extend(const label minSize)
Ensure that minSize is covered by the bitSet.
Definition bitSetI.H:587
label unset(const IndirectListBase< label, Addr > &locations)
Unset the listed locations, never auto-vivifies.
label find_first() const
Locate the first bit that is set.
Definition bitSetI.H:260
A range or interval of labels defined by a start and a size.
Definition labelRange.H:66
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition className.H:74
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Unary negation.
bitSet operator~(const bitSet &bitset)
Bitset complement, returns a copy of the bitset with all its bits flipped.
Definition bitSetI.H:674
dimensionedScalar pos(const dimensionedScalar &ds)
bitSet operator|(const bitSet &a, const bitSet &b)
Bitwise-OR of two bitsets.
Definition bitSetI.H:692
const T & NullObjectRef() noexcept
Const reference (of type T) to the nullObject.
Definition nullObject.H:228
List< label > labelList
A List of labels.
Definition List.H:62
bitSet operator^(const bitSet &a, const bitSet &b)
Bitwise-XOR of two bitsets to form a unique bit-set.
Definition bitSetI.H:702
const direction noexcept
Definition scalarImpl.H:265
UList< label > labelUList
A UList of labels.
Definition UList.H:75
volScalarField & b
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...
Definition Hash.H:48
const Vector< label > N(dict.get< Vector< label > >("N"))