/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . Class Foam::bitSet Description A bitSet stores bits (elements with only two states) in packed internal format and supports a variety of bit-set operations. Its behaviour is largely list-like, with some HashSet features. SourceFiles bitSetI.H bitSet.C bitSetIO.C bitSetTemplates.C See also Foam::BitOps Foam::PackedList \*---------------------------------------------------------------------------*/ #ifndef bitSet_H #define bitSet_H #include "className.H" #include "PackedList.H" #include "UIndirectList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { // Forward declarations class bitSet; class labelRange; /*---------------------------------------------------------------------------*\ Class bitSet Declaration \*---------------------------------------------------------------------------*/ class bitSet : public PackedList<1> { private: // Private Member Functions //- Find the first block with a '0' bit // \return block number or -1 if the set is empty or all bits are on. inline label first_not_block() const; protected: // Protected Member Functions //- Write as a dictionary entry void writeEntry(Ostream& os) const; // Logic/Set Operations //- The set difference // \code // A = (A - B) // A = (A & !B) // A = (A & ~B) // \endcode // A and B can have different sizes. // Does not change the original set size. bitSet& minusEq(const bitSet& other); //- The set logical AND // \code // A = (A & B) // // \endcode // A and B can have different sizes.. // Does not change the original set size. bitSet& andEq(const bitSet& other); //- The set logical OR // \code // A = (A | B) // \endcode // A and B can have different sizes // // \note // The default (strict=true) ignores additional length from B, // whereas (strict=false) permits the set to automatically grow // to accommodate additional elements arising from B. bitSet& orEq(const bitSet& other, const bool strict=true); //- The set logical XOR // \code // A = (A ^ B) // \endcode // A and B can have different sizes. Sizing behaviour as per orEq. bitSet& xorEq(const bitSet& other, const bool strict=true); public: // Forward declaration of access classes class reference; class const_iterator; typedef unsigned int const_reference; //- Define class name and debug ClassName("bitSet"); // Constructors //- Construct an empty, zero-sized set inline constexpr bitSet() noexcept; //- Construct from Istream explicit bitSet(Istream& is); //- Construct with given size, with all bits set to 0 explicit inline bitSet(const label n); //- Construct with given size and value for all elements inline bitSet(const label n, const bool val); //- Copy construct inline bitSet(const bitSet& bitset); //- Move construct inline bitSet(bitSet&& bitset); //- Construct from a list of bools explicit inline bitSet(const UList& bools); //- Construct with given size with all bits set to 0, //- subsequently add specified locations as 1. inline bitSet(const label n, const labelUList& locations); //- Construct with given size with all bits set to 0, //- subsequently add specified locations as 1. inline bitSet(const label n, const labelUIndList& locations); //- Construct with given size with all bits set to 0, //- subsequently add specified locations as 1. inline bitSet(const label n, std::initializer_list