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-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::bitSet
28 
29 Description
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 
34 SourceFiles
35  bitSetI.H
36  bitSet.C
37  bitSetIO.C
38  bitSetTemplates.C
39 
40 See also
41  Foam::BitOps
42  Foam::PackedList
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef Foam_bitSet_H
47 #define Foam_bitSet_H
48 
49 #include "className.H"
50 #include "PackedList.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 // Forward Declarations
58 class bitSet;
59 
60 /*---------------------------------------------------------------------------*\
61  Class bitSet Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class bitSet
65 :
66  public PackedList<1>
67 {
68  // Private Member Functions
69 
70  //- Find the first block with a '0' bit
71  // \return block number or -1 if the set is empty or all bits are on.
72  inline label first_not_block() const;
73 
74 
75 protected:
76 
77  // Logic/Set Operations
78 
79  //- The set difference
80  // \code
81  // A = (A - B)
82  // A = (A & !B)
83  // A = (A & ~B)
84  // \endcode
85  // A and B can have different sizes.
86  // Never changes the original set size.
87  // Non-overlapping parts are considered \em off.
88  bitSet& minusEq(const bitSet& other);
89 
90  //- The set logical AND
91  // \code
92  // A = (A & B)
93  //
94  // \endcode
95  // A and B can have different sizes.
96  // Never changes the original set size.
97  // Non-overlapping parts are considered \em off.
98  bitSet& andEq(const bitSet& other);
99 
100  //- The set logical OR
101  // \code
102  // A = (A | B)
103  // \endcode
104  // A and B can have different sizes
105  //
106  // The size grows to accommodate new \em on bits.
107  bitSet& orEq(const bitSet& other);
108 
109  //- The set logical XOR
110  // \code
111  // A = (A ^ B)
112  // \endcode
113  // A and B can have different sizes.
114  //
115  // The size grows to accommodate new \em on bits.
116  bitSet& xorEq(const bitSet& other);
117 
118 
119 public:
120 
121  // Forward declaration of access classes
122 
123  class reference;
124  class const_iterator;
125  typedef unsigned int const_reference;
126 
127 
128  // Static Member Functions
129 
130  //- Return a null bitSet reference
131  inline static const bitSet& null();
132 
133 
134  //- Declare type-name (with debug switch)
135  ClassName("bitSet");
136 
137 
138  // Constructors
139 
140  //- Default construct an empty, zero-sized bitSet
141  inline bitSet() noexcept;
142 
143  //- Construct from Istream
144  explicit bitSet(Istream& is);
145 
146  //- Construct with given size, with all bits set to 0
147  inline explicit bitSet(const label n);
148 
149  //- Construct with given size and value for all elements
150  inline bitSet(const label n, const bool val);
151 
152  //- Copy construct
153  inline bitSet(const bitSet& bitset);
154 
155  //- Move construct
156  inline bitSet(bitSet&& bitset);
157 
158  //- Construct a new bitSet by extracting the specified (unique)
159  //- locations of an existing bitSet.
160  bitSet(const bitSet& bitset, const labelUList& addr);
161 
162  //- Construct a new set by extracting the specified (unique)
163  //- locations of an existing bitSet.
164  template<class Addr>
165  bitSet
166  (
167  const bitSet& bitset,
168  const IndirectListBase<label, Addr>& addr
169  );
170 
171  //- Construct a new bitSet by extracting the specified range
172  //- locations of an existing bitSet.
173  bitSet(const bitSet& bitset, const labelRange& range);
174 
175  //- Construct from a list of bools
176  inline explicit bitSet(const UList<bool>& bools);
177 
178  //- Construct with given pre-size (filled with 0),
179  //- subsequently add specified locations as 1,
180  //- auto-vivify entries if needed.
181  explicit bitSet(const label n, const labelRange& range);
182 
183  //- Construct with given pre-size (filled with 0),
184  //- subsequently add specified locations as 1,
185  //- auto-vivify entries if needed.
186  inline bitSet(const label n, const labelUList& locations);
187 
188  //- Construct with given pre-size (filled with 0),
189  //- subsequently add specified locations as 1,
190  //- auto-vivify entries if needed.
191  template<class Addr>
192  bitSet
193  (
194  const label n,
195  const IndirectListBase<label, Addr>& locations
196  );
197 
198  //- Construct with given pre-size (filled with 0),
199  //- subsequently add specified locations as 1,
200  //- auto-vivify entries if needed.
201  template<unsigned N>
202  bitSet(const label n, const FixedList<label, N>& locations);
203 
204  //- Construct with given pre-size (filled with 0),
205  //- subsequently add specified locations as 1,
206  //- auto-vivify entries if needed.
207  inline bitSet(const label n, std::initializer_list<label> locations);
208 
209  //- Construct with automatic sizing (filled with 0),
210  //- and set the specified locations as 1.
211  explicit bitSet(const labelRange& range);
212 
213  //- Construct with automatic sizing (filled with 0),
214  //- and set the specified locations as 1.
215  inline explicit bitSet(const labelUList& locations);
216 
217  //- Construct with automatic sizing (filled with 0),
218  //- and set the specified locations as 1.
219  template<class Addr>
220  inline explicit bitSet(const IndirectListBase<label, Addr>& locations);
221 
222  //- Construct with automatic sizing (filled with 0),
223  //- and set the specified locations as 1.
224  template<unsigned N>
225  explicit bitSet(const FixedList<label, N>& locations);
226 
227  //- Clone
228  inline autoPtr<bitSet> clone() const;
229 
230 
231  // Member Functions
232 
233  // Query
234 
235  //- True if all bits in this bitset are set or if the set is \b empty.
236  // Returning true for an empty set may not seem intuitive, but
237  // conforms with boost definitions and std::all_of behaviour.
238  // \note Method name compatibility with boost::dynamic_bitset
239  inline bool all() const;
240 
241  //- True if any bits in this bitset are set.
242  // \note Method name compatibility with boost::dynamic_bitset
243  inline bool any() const;
244 
245  //- True if no bits in this bitset are set.
246  // \note Method name compatibility with boost::dynamic_bitset
247  inline bool none() const;
248 
249  //- True if all entries have identical values, and the set is non-empty
250  inline bool uniform() const;
251 
252  //- Count number of bits set.
253  // \param on can be set to false to count the number of unset bits
254  // instead.
255  // \note Method name compatibility with boost::dynamic_bitset
256  inline unsigned int count(const bool on=true) const;
257 
258  //- True if any bits in the other bitset intersect (are the same).
259  //
260  // \note Method name compatibility with boost::dynamic_bitset
261  bool intersects(const bitSet& other) const;
262 
263  //- Test for \em True value at specified position,
264  //- never auto-vivify entries.
265  //
266  // \note Method name compatibility with std::bitset
267  bool test(const label pos) const { return this->get(pos); }
268 
269  //- Test for \em True value at specified position,
270  //- never auto-vivify entries.
271  //
272  // \note Method name compatibility with HashSet
273  bool contains(const label pos) const { return this->get(pos); }
274 
275  //- Locate the first bit that is set.
276  // \return the location or -1 if there are no bits set.
277  //
278  // \note Method name compatibility with boost::dynamic_bitset
279  inline label find_first() const;
280 
281  //- Locate the first bit that is unset.
282  // \return the location or -1 if the set is empty or all bits are on.
283  //
284  // \note Provided for symmetry with find_first()
285  inline label find_first_not() const;
286 
287  //- Locate the last bit set.
288  // \return the location or -1 if there are no bits set.
289  //
290  // \note Provided for symmetry with find_first()
291  inline label find_last() const;
292 
293  //- Locate the next bit set, starting one beyond the specified position
294  // \return the location or -1 if there are no further bits set.
295  //
296  // \note Method name compatibility with boost::dynamic_bitset
297  inline label find_next(label pos) const;
298 
299  //- The indices of the \a on bits as a sorted labelList.
300  //
301  // \note Method name compatibility with HashSet
302  labelList toc() const;
303 
304  //- The indices of the \a on bits as a sorted labelList.
305  // This is identical to toc(), which is always sorted.
306  //
307  // \note Method name compatibility with HashSet
308  inline labelList sortedToc() const;
309 
310  //- Return the bitset values as a boolList.
311  // When the output is a bool, this is more efficient than unpack()
312  List<bool> values() const;
313 
314 
315  // Assignment
316 
317  //- Assign all entries to the given value.
318  inline void fill(const bool val);
319 
320  //- Copy assign all entries from a list of bools.
321  void assign(const UList<bool>& bools);
322 
323 
324  // Setting single or multiple values
325 
326  //- Assign a single index/value
327  using PackedList<1>::set;
328 
329  //- Set specified bits from another bitset.
330  // The current set size may grow to accommodate any new bits
331  // (auto-vivifies).
332  inline void set(const bitSet& bitset);
333 
334  //- Set the specified range of bits
335  // The current set size may grow to accommodate any new bits
336  // (auto-vivifies).
337  // \note this operation is generally more efficient than calling
338  // set(pos) on individual bits.
339  void set(const labelRange& range);
340 
342  // Unsetting single or multiple values
343 
344  //- Unset a single index
345  using PackedList<1>::unset;
346 
347  //- Unset (subtract) the bits specified in the other bitset, which is
348  //- a set difference corresponds to the logical operation
349  // \code
350  // A = (A & !B)
351  // \endcode
352  // The result is comparable to 'operator-='
353  // \endcode
354  //
355  // A and B can have different sizes.
356  // Does not change the original set size.
357  inline bitSet& unset(const bitSet& other);
358 
359  //- Unset the specified range of bits specified, never auto-vivifies.
360  // \note this operation can be more efficient than calling
361  // unset(pos) on individual bits.
362  void unset(const labelRange& range);
363 
364 
365  // Edit
366 
367  //- Invert all bits in the addressable region
368  inline void flip();
369 
370  //- Invert bit at the specified position.
371  // A no-op if the position is out-of-range
372  inline void flip(const label pos);
373 
374  //- Resize to include the last \em on bit only.
375  // Functionally identical to resize(find_last()+1)
376  inline void resize_last();
377 
378  //- Swap contents
379  inline void swap(bitSet& bitset);
380 
381  //- Transfer the contents of the argument list into this list
382  //- and annul the argument list.
383  inline void transfer(bitSet& bitset);
384 
385 
386  // Convenience methods
387 
388  //- Ensure the addressable range does not exceed maxSize.
389  // Either decreases the size of the bitSet or is a no-op.
390  //
391  // \code
392  // pointField& pts = mesh.points();
393  // bitset.bound(pts.size());
394  //
395  // for (const label pointi : bitset)
396  // {
397  // pts[pointi] ...
398  // }
399  // \endcode
400  inline bitSet& bound(const label maxSize);
401 
402  //- Ensure the addressable range does not exceed that of other.
403  // Either decreases the size of the bitSet or is a no-op.
404  inline bitSet& bound(const bitSet& other);
405 
406  //- Ensure that minSize is covered by the bitSet.
407  // Either increases the size of the bitSet or is a no-op.
408  inline bitSet& extend(const label minSize);
409 
410  //- Ensure the bitset is addressable throughout the range of other.
411  // Either increases the size of the bitSet or is a no-op.
412  inline bitSet& extend(const bitSet& other);
413 
414  //- Set the locations listed by the iterator range,
415  //- auto-vivify entries if needed.
416  //
417  // \return number of locations changed
418  template<class InputIter>
419  label setMany(InputIter first, InputIter last);
420 
421  //- Set the listed locations to 1.
422  // Does auto-vivify for non-existent entries.
423  //
424  // \return number of locations changed
425  inline label set(const labelUList& locations);
426 
427  //- Set the listed locations to 1.
428  // Does auto-vivify for non-existent entries.
429  //
430  // \return number of locations changed
431  template<class Addr>
432  inline label set(const IndirectListBase<label, Addr>& locations);
433 
434  //- Set the listed locations to 1.
435  // Does auto-vivify for non-existent entries.
436  //
437  // \return number of locations changed
438  template<unsigned N>
439  label set(const FixedList<label, N>& locations);
440 
441  //- Unset the locations listed by the iterator range,
442  //- never auto-vivify entries.
443  //
444  // \return number of locations changed
445  template<class InputIter>
446  label unset(InputIter first, InputIter last);
447 
448  //- Unset the listed locations, never auto-vivifies.
449  //
450  // \return number of locations changed
451  inline label unset(const labelUList& locations);
452 
453  //- Unset the listed locations, never auto-vivifies.
454  //
455  // \return number of locations changed
456  template<class Addr>
457  inline label unset(const IndirectListBase<label, Addr>& locations);
458 
459  //- Unset the listed locations, never auto-vivifies.
460  //
461  // \return number of locations changed
462  template<unsigned N>
463  label unset(const FixedList<label, N>& locations);
464 
465 
466  // Access helpers
467 
468  //- A reference supporting read/write access to an entry
469  class reference
470  :
471  public PackedList<1>::reference
472  {
473  protected:
474 
475  friend class bitSet; // Access for parent
476  void operator&() = delete; // Refuse to provide its address
477 
478  //- Construct by taking reference of block from within
479  //- the list and the specified index.
480  inline reference(bitSet* parent, const label index);
481 
482  public:
483 
484  //- Copy construct
485  reference(const reference&) = default;
486 
487  //- Move construct
488  reference(reference&&) = default;
489 
490  //- Flip the bit at the position, no range-checking
491  inline void flip();
492 
493  //- Value assignment
494  inline void operator=(const reference& other);
495 
496  //- Value assignment
497  inline void operator=(const unsigned int val);
498 
499  //- Conversion operator
500  inline operator unsigned int () const;
501  };
502 
503 
504  // Iteration
505 
506  //- A const_iterator for iterating across \a on values
507  class const_iterator
508  {
509  friend class bitSet;
510 
511  //- The parent being iterated
512  const bitSet* set_;
513 
514  //- Global position of the current \a on bit
515  label pos_;
516 
517  //- Default construct - an end iterator
518  inline const_iterator() noexcept;
519 
520  //- Construct begin iterator
521  inline const_iterator(const bitSet* bitset);
522 
523  //- Construct iterator, starting at or beyond the given position
524  inline const_iterator(const bitSet* bitset, label pos);
525 
526  public:
527 
528  //- Return the current \a on position
529  inline label operator*() const noexcept;
530 
531  //- Move to the next \a on position
532  inline const_iterator& operator++();
533 
534  inline bool operator==(const const_iterator& iter) const noexcept;
535  inline bool operator!=(const const_iterator& iter) const noexcept;
536  };
537 
538 
539  //- Iterator set to the position of the first \a on bit
540  inline const_iterator begin() const;
541 
542  //- Iterator set to the position of the first \a on bit
543  inline const_iterator cbegin() const;
544 
545  //- Iterator set to the position of the first \a on bit that occurs
546  //- at or beyond the given position
547  inline const_iterator begin(label pos) const;
548 
549  //- Iterator set to the position of the first \a on bit that occurs
550  //- at or beyond the given position
551  inline const_iterator cbegin(label pos) const;
552 
553  //- Iterator beyond the end of the bitSet
554  inline const_iterator end() const noexcept;
555 
556  //- Iterator beyond the end of the bitSet
557  inline const_iterator cend() const noexcept;
558 
559 
560  // Member Operators
561 
562  //- Test value at specified position, same as test()
563  // Enables use as a predicate
564  inline bool operator()(const label pos) const;
565 
566  //- Identical to get() - get value at index.
567  // Never auto-vivify entries.
568  inline unsigned int operator[](const label i) const;
569 
570  //- Non-const access to value at index.
571  // Fatal for out-of-range indices
572  inline reference operator[](const label i);
573 
574  //- Copy assignment
575  inline bitSet& operator=(const bitSet& bitset);
576 
577  //- Move assignment
578  inline bitSet& operator=(bitSet&& bitset);
579 
580  //- Assign all entries to the given value. fill()
581  inline bitSet& operator=(const bool val);
582 
583  //- Bitwise-AND all the bits in other with the bits in this bitset.
584  // The operands may have dissimilar sizes,
585  // never changes the original set size.
586  // Non-overlapping elements are considered \em off.
587  inline bitSet& operator&=(const bitSet& other);
588 
589  //- Bitwise-OR operator - similar to the set() method.
590  // The operands may have dissimilar sizes,
591  // the set grows to accommodate new \em on bits.
592  inline bitSet& operator|=(const bitSet& other);
593 
594  //- Bitwise-XOR operator - retains unique entries.
595  // The operands may have dissimilar sizes,
596  // the set grows to accommodate new \em on bits.
597  inline bitSet& operator^=(const bitSet& other);
598 
599  //- Remove entries from this list - identical to the unset() method.
600  // The operands may have dissimilar sizes,
601  // never changes the original set size.
602  inline bitSet& operator-=(const bitSet& other);
603 
604 
605  // IOstream Operators
606 
607  //- Return info proxy,
608  //- used to print information to a stream
609  InfoProxy<bitSet> info() const noexcept
610  {
611  return *this;
612  }
613 
614 
615  // Housekeeping
616 
617  //- Same as contains()
618  bool found(const label pos) const { return this->contains(pos); }
619 
620  //- Deprecated(2020-11) use fill()
621  // \deprecated(2020-11) use fill()
622  void assign(const unsigned int val) { this->fill(val); }
623 };
624 
625 
626 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
627 
628 //- Hashing for bitSet data
629 template<> struct Hash<bitSet> : bitSet::hasher {};
630 
631 
632 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
633 
634 //- Write bitset to Ostream with 40 items per line.
635 Ostream& operator<<(Ostream& os, const bitSet& bitset);
636 
637 //- Output bitset information
638 Ostream& operator<<(Ostream& os, const InfoProxy<bitSet>& iproxy);
639 
640 
641 //- Bitset complement, returns a copy of the bitset with all its bits flipped
642 inline bitSet operator~(const bitSet& bitset);
644 //- Bitwise-AND of two bitsets.
645 // See bitSet::operator&= for more details.
646 inline bitSet operator&(const bitSet& a, const bitSet& b);
647 
648 //- Bitwise-OR of two bitsets
649 // See bitSet::operator|= for more details.
650 inline bitSet operator|(const bitSet& a, const bitSet& b);
651 
652 //- Bitwise-XOR of two bitsets to form a unique bit-set
653 // See bitSet::operator^= for more details.
654 inline bitSet operator^(const bitSet& a, const bitSet& b);
655 
656 //- Bitwise difference (subset) of two bitsets to form a unique bit-set
657 // See bitSet::operator-= for more details.
658 inline bitSet operator-(const bitSet& a, const bitSet& b);
659 
660 
661 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
662 
663 } // End namespace Foam
664 
665 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
666 
667 #include "bitSetI.H"
668 
669 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
670 
671 #ifdef NoRepository
672  #include "bitSetTemplates.C"
673 #endif
674 
675 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
676 
677 #endif
678 
679 // ************************************************************************* //
A reference supporting read/write access to an entry.
Definition: bitSet.H:637
unsigned int count(const bool on=true) const
Count number of bits set.
Definition: bitSetI.H:493
bitSet & orEq(const bitSet &other)
The set logical OR.
Definition: bitSet.C:122
label setMany(InputIter first, InputIter last)
Set the locations listed by the iterator range, auto-vivify entries if needed.
void fill(const bool val)
Assign all entries to the given value.
Definition: bitSetI.H:547
bitSet operator~(const bitSet &bitset)
Bitset complement, returns a copy of the bitset with all its bits flipped.
Definition: bitSetI.H:743
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:101
void operator &()=delete
label find_last() const
Locate the last bit set.
Definition: bitSetI.H:368
unsigned int const_reference
Definition: bitSet.H:134
bool found(const label pos) const
Same as contains()
Definition: bitSet.H:859
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:51
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void flip()
Invert all bits in the addressable region.
Definition: bitSetI.H:615
reference(bitSet *parent, const label index)
Construct by taking reference of block from within the list and the specified index.
Definition: bitSetI.H:172
List< bool > values() const
Return the bitset values as a boolList.
Definition: bitSet.C:506
labelList sortedToc() const
The indices of the on bits as a sorted labelList.
Definition: bitSetI.H:514
label find_first() const
Locate the first bit that is set.
Definition: bitSetI.H:307
bitSet() noexcept
Default construct an empty, zero-sized bitSet.
Definition: bitSetI.H:70
InfoProxy< bitSet > info() const noexcept
Return info proxy, used to print information to a stream.
Definition: bitSet.H:848
void flip()
Flip the bit at the position, no range-checking.
Definition: bitSetI.H:181
bitSet & minusEq(const bitSet &other)
The set difference.
Definition: bitSet.C:35
label find_next(label pos) const
Locate the next bit set, starting one beyond the specified position.
Definition: bitSetI.H:394
const_iterator begin() const
Iterator set to the position of the first on bit.
Definition: bitSetI.H:271
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
bitSet & xorEq(const bitSet &other)
The set logical XOR.
Definition: bitSet.C:167
bitSet operator|(const bitSet &a, const bitSet &b)
Bitwise-OR of two bitsets.
Definition: bitSetI.H:761
void resize_last()
Resize to include the last on bit only.
Definition: bitSetI.H:520
label find_first_not() const
Locate the first bit that is unset.
Definition: bitSetI.H:336
scalar range
bool any() const
True if any bits in this bitset are set.
Definition: bitSetI.H:462
dimensionedScalar pos(const dimensionedScalar &ds)
autoPtr< bitSet > clone() const
Clone.
Definition: bitSetI.H:163
ClassName("bitSet")
Declare type-name (with debug switch)
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
Definition: PackedList.H:104
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:609
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
static const bitSet & null()
Return a null bitSet reference.
Definition: bitSetI.H:448
bool set(const label i, unsigned int val=~0u)
Set value at index i, default value set is the max_value.
Definition: PackedListI.H:639
void operator=(const reference &other)
Value assignment.
Definition: bitSetI.H:189
void transfer(bitSet &bitset)
Transfer the contents of the argument list into this list and annul the argument list.
Definition: bitSetI.H:541
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Unary negation.
bool test(const label pos) const
Test for True value at specified position, never auto-vivify entries.
Definition: bitSet.H:341
const_iterator cend() const noexcept
Iterator beyond the end of the bitSet.
Definition: bitSetI.H:301
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
const direction noexcept
Definition: Scalar.H:258
List< bool > bools(const labelHashSet &locations)
Transform the on locations to a boolList, with true for each non-negative location and false for all ...
Definition: HashOps.C:72
bitSet & andEq(const bitSet &other)
The set logical AND.
Definition: bitSet.C:70
OBJstream os(runTime.globalPath()/outputName)
friend Ostream & operator(Ostream &os, const InfoProxy< PackedList< Width >> &info)
labelList toc() const
The indices of the on bits as a sorted labelList.
Definition: bitSet.C:467
const Vector< label > N(dict.get< Vector< label >>("N"))
bitSet operator^(const bitSet &a, const bitSet &b)
Bitwise-XOR of two bitsets to form a unique bit-set.
Definition: bitSetI.H:771
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:76
A const_iterator for iterating across on values.
Definition: bitSet.H:691
A helper class for outputting values to Ostream.
Definition: ensightCells.H:43
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
bool contains(const label pos) const
Test for True value at specified position, never auto-vivify entries.
Definition: bitSet.H:350
tmp< GeometricField< Type, faPatchField, areaMesh > > operator &(const faMatrix< Type > &, const DimensionedField< Type, areaMesh > &)
Macro definitions for declaring ClassName(), NamespaceName(), etc.
const_iterator cbegin() const
Iterator set to the position of the first on bit.
Definition: bitSetI.H:277
void assign(const UList< bool > &bools)
Copy assign all entries from a list of bools.
Definition: bitSet.C:267
bool intersects(const bitSet &other) const
True if any bits in the other bitset intersect (are the same).
Definition: bitSet.C:287
label n
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
List< label > labelList
A List of labels.
Definition: List.H:62
const_iterator end() const noexcept
Iterator beyond the end of the bitSet.
Definition: bitSetI.H:295
void swap(bitSet &bitset)
Swap contents.
Definition: bitSetI.H:535
bitSet & extend(const label minSize)
Ensure that minSize is covered by the bitSet.
Definition: bitSetI.H:656
bool none() const
True if no bits in this bitset are set.
Definition: bitSetI.H:481
bitSet bitset(const labelHashSet &locations)
Transform the on locations to a bitSet.
Definition: HashOps.C:63
bool all() const
True if all bits in this bitset are set or if the set is empty.
Definition: bitSetI.H:454
bitSet & bound(const label maxSize)
Ensure the addressable range does not exceed maxSize.
Definition: bitSetI.H:639
Namespace for OpenFOAM.