mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: minor adjustment to BitOps and PackedList
- extend toc/sortedToc wrappers to bitSet and labelHashSet to allow use of BitOps::toc(...) in templated code - size_data() method to return the number of addressed integer blocks similar to size_bytes() does, but for int instead of char.
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -205,6 +205,30 @@ Foam::List<Foam::label> Foam::BitOps::sortedToc(const UList<bool>& bools)
|
||||
}
|
||||
|
||||
|
||||
Foam::List<Foam::label> Foam::BitOps::toc(const bitSet& bitset)
|
||||
{
|
||||
return bitset.toc();
|
||||
}
|
||||
|
||||
|
||||
Foam::List<Foam::label> Foam::BitOps::sortedToc(const bitSet& bitset)
|
||||
{
|
||||
return bitset.sortedToc();
|
||||
}
|
||||
|
||||
|
||||
Foam::List<Foam::label> Foam::BitOps::toc(const labelHashSet& hashset)
|
||||
{
|
||||
return hashset.sortedToc();
|
||||
}
|
||||
|
||||
|
||||
Foam::List<Foam::label> Foam::BitOps::sortedToc(const labelHashSet& hashset)
|
||||
{
|
||||
return hashset.sortedToc();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * BitSetOps * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::bitSet Foam::BitSetOps::create
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -163,6 +163,28 @@ List<label> toc(const UList<bool>& bools);
|
||||
List<label> sortedToc(const UList<bool>& bools);
|
||||
|
||||
|
||||
//- Forward to bitSet::toc(), the sorted values of the 'on' entries.
|
||||
//
|
||||
// \return a List of labels
|
||||
List<label> toc(const bitSet& bitset);
|
||||
|
||||
//- Forward to bitSet::sortedToc(), the sorted values of the 'on' entries.
|
||||
//
|
||||
// \return a List of labels
|
||||
List<label> sortedToc(const bitSet& bitset);
|
||||
|
||||
|
||||
//- Forward to labelHashSet::sortedToc(), the sorted values of the 'on' entries.
|
||||
//
|
||||
// \return a List of labels
|
||||
List<label> toc(const labelHashSet& hashset);
|
||||
|
||||
//- Forward to labelHashSet::sortedToc(), the sorted values of the 'on' entries.
|
||||
//
|
||||
// \return a List of labels
|
||||
List<label> sortedToc(const labelHashSet& hashset);
|
||||
|
||||
|
||||
//- Count arbitrary number of bits (of an integral type)
|
||||
template<class UIntType>
|
||||
inline unsigned int bit_count(UIntType x)
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -409,6 +409,9 @@ public:
|
||||
//- A pointer to the raw storage, reinterpreted as byte data
|
||||
inline char* data_bytes() noexcept;
|
||||
|
||||
//- The number of integer blocks addressed in the raw storage
|
||||
inline std::streamsize size_data() const noexcept;
|
||||
|
||||
//- The number of bytes used in the raw storage
|
||||
//- including any unused padding.
|
||||
inline std::streamsize size_bytes() const noexcept;
|
||||
|
||||
@ -571,6 +571,13 @@ inline char* Foam::PackedList<Width>::data_bytes() noexcept
|
||||
}
|
||||
|
||||
|
||||
template<unsigned Width>
|
||||
inline std::streamsize Foam::PackedList<Width>::size_data() const noexcept
|
||||
{
|
||||
return num_blocks(size());
|
||||
}
|
||||
|
||||
|
||||
template<unsigned Width>
|
||||
inline std::streamsize Foam::PackedList<Width>::size_bytes() const noexcept
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user