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