/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ 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::PackedBoolList
Description
A bit-packed bool list.
In addition to the obvious memory advantage over using a
List\, this class also provides a number of bit-like
operations.
SourceFiles
PackedBoolListI.H
PackedBoolList.C
SeeAlso
Foam::PackedList
\*---------------------------------------------------------------------------*/
#ifndef PackedBoolList_H
#define PackedBoolList_H
#include "PackedList.H"
#include "UIndirectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration
class PackedBoolList;
//- \typedef A List of PackedBoolList
typedef List PackedBoolListList;
/*---------------------------------------------------------------------------*\
Class PackedBoolList Declaration
\*---------------------------------------------------------------------------*/
class PackedBoolList
:
public PackedList<1>
{
// Private Member Functions
//- Preparation, resizing before a bitor operation
// returns true if the later result needs trimming
bool bitorPrepare(const PackedList<1>& lst, label& maxPackLen);
//- Set the listed indices. Return number of elements changed.
// Does auto-vivify for non-existent entries.
template
label setIndices(const LabelListType& indices);
//- Unset the listed indices. Return number of elements changed.
// Never auto-vivify entries.
template
label unsetIndices(const LabelListType& indices);
//- Subset with the listed indices. Return number of elements subsetted.
template
label subsetIndices(const LabelListType& indices);
public:
// Constructors
//- Construct null
inline PackedBoolList();
//- Construct from Istream
PackedBoolList(Istream&);
//- Construct with given size, initializes list to 0
explicit inline PackedBoolList(const label size);
//- Construct with given size and value for all elements
inline PackedBoolList(const label size, const bool val);
//- Copy constructor
inline PackedBoolList(const PackedBoolList&);
//- Copy constructor
explicit inline PackedBoolList(const PackedList<1>&);
//- Construct by transferring the parameter contents
inline PackedBoolList(const Xfer&);
//- Construct by transferring the parameter contents
inline PackedBoolList(const Xfer>&);
//- Construct from a list of bools
explicit inline PackedBoolList(const Foam::UList&);
//- Construct from a list of labels
// using the labels as indices to indicate which bits are set
explicit inline PackedBoolList(const labelUList& indices);
//- Construct from a list of labels
// using the labels as indices to indicate which bits are set
explicit inline PackedBoolList(const UIndirectList