mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add bitSet::begin(pos) to provide alternative start for indexing
This commit is contained in:
committed by
Andrew Heather
parent
d4a0dc631c
commit
1dde76c8dd
@ -412,6 +412,30 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Test begin vs find_first etc
|
||||||
|
{
|
||||||
|
// Clear some values
|
||||||
|
list4.unset(labelRange(0, 10));
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "Test first vs begin" << nl
|
||||||
|
<< " values:" << flatOutput(list4.toc()) << nl
|
||||||
|
<< " first:" << list4.find_first() << nl
|
||||||
|
<< " begin:" << *(list4.begin()) << nl
|
||||||
|
<< " begin(0):" << *(list4.begin(0)) << nl;
|
||||||
|
|
||||||
|
// With offset
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "Test first vs begin" << nl
|
||||||
|
<< " next(35):" << list4.find_next(35)
|
||||||
|
<< " begin(35):" << *(list4.begin(35)) << nl
|
||||||
|
<< " next(40):" << list4.find_next(40)
|
||||||
|
<< " begin(40):" << *(list4.begin(40)) << nl
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Construct from labelUList, labelUIndList
|
// Construct from labelUList, labelUIndList
|
||||||
{
|
{
|
||||||
DynamicList<label> indices({10, 50, 300});
|
DynamicList<label> indices({10, 50, 300});
|
||||||
|
|||||||
@ -478,6 +478,9 @@ public:
|
|||||||
//- Construct begin iterator
|
//- Construct begin iterator
|
||||||
inline const_iterator(const bitSet* bitset);
|
inline const_iterator(const bitSet* bitset);
|
||||||
|
|
||||||
|
//- Construct iterator, starting at or beyond the given position
|
||||||
|
inline const_iterator(const bitSet* bitset, label pos);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Return the current \a on position
|
//- Return the current \a on position
|
||||||
@ -497,6 +500,14 @@ public:
|
|||||||
//- Iterator set to the position of the first \a on bit
|
//- Iterator set to the position of the first \a on bit
|
||||||
inline const_iterator cbegin() const;
|
inline const_iterator cbegin() const;
|
||||||
|
|
||||||
|
//- Iterator set to the position of the first \a on bit that occurs
|
||||||
|
//- at or beyond the given position
|
||||||
|
inline const_iterator begin(label pos) const;
|
||||||
|
|
||||||
|
//- Iterator set to the position of the first \a on bit that occurs
|
||||||
|
//- at or beyond the given position
|
||||||
|
inline const_iterator cbegin(label pos) const;
|
||||||
|
|
||||||
//- Iterator beyond the end of the bitSet
|
//- Iterator beyond the end of the bitSet
|
||||||
inline const_iterator end() const noexcept;
|
inline const_iterator end() const noexcept;
|
||||||
|
|
||||||
|
|||||||
@ -230,6 +230,17 @@ inline Foam::bitSet::const_iterator::const_iterator(const bitSet* parent)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::bitSet::const_iterator::const_iterator
|
||||||
|
(
|
||||||
|
const bitSet* parent,
|
||||||
|
label pos
|
||||||
|
)
|
||||||
|
:
|
||||||
|
set_(parent),
|
||||||
|
pos_(set_->find_next(pos-1))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::label Foam::bitSet::const_iterator::operator*() const noexcept
|
inline Foam::label Foam::bitSet::const_iterator::operator*() const noexcept
|
||||||
{
|
{
|
||||||
return pos_;
|
return pos_;
|
||||||
@ -273,6 +284,18 @@ inline Foam::bitSet::const_iterator Foam::bitSet::cbegin() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::bitSet::const_iterator Foam::bitSet::begin(label pos) const
|
||||||
|
{
|
||||||
|
return const_iterator(this, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::bitSet::const_iterator Foam::bitSet::cbegin(label pos) const
|
||||||
|
{
|
||||||
|
return const_iterator(this, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::bitSet::const_iterator Foam::bitSet::end() const noexcept
|
inline Foam::bitSet::const_iterator Foam::bitSet::end() const noexcept
|
||||||
{
|
{
|
||||||
return const_iterator();
|
return const_iterator();
|
||||||
|
|||||||
Reference in New Issue
Block a user