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