ENH: make sliceRange modifiable - similar to labelRange
This commit is contained in:
parent
a0b9732321
commit
d6d28ccfa2
@ -1,3 +1,3 @@
|
||||
Test-sliceRange.C
|
||||
Test-sliceRange.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-sliceRange
|
||||
|
@ -25,6 +25,7 @@ License
|
||||
|
||||
Description
|
||||
Test slice range
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
@ -157,7 +158,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Some iterator tests
|
||||
{
|
||||
const sliceRange range(25, 8, 3);
|
||||
sliceRange range(25, 8, 3);
|
||||
|
||||
auto iter1 = range.begin();
|
||||
Info<< nl << "Forward iterator for " << range << nl;
|
||||
@ -166,6 +167,16 @@ int main(int argc, char *argv[])
|
||||
auto iter2 = range.rbegin();
|
||||
Info<< nl << "Reverse iterator for " << range << nl;
|
||||
printIteratorTest(iter2);
|
||||
|
||||
|
||||
// Change the start, size
|
||||
range.start() = 5;
|
||||
range.size() = 4;
|
||||
|
||||
iter1 = range.begin();
|
||||
|
||||
Info<< nl << "Forward iterator for " << range << nl;
|
||||
printIteratorTest(iter1);
|
||||
}
|
||||
|
||||
|
@ -112,23 +112,33 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- The start value in the range
|
||||
constexpr label start() const noexcept { return start_; }
|
||||
|
||||
//- The size of the range
|
||||
constexpr label size() const noexcept { return size_; }
|
||||
|
||||
//- The stride for the range
|
||||
constexpr label stride() const noexcept { return stride_; }
|
||||
|
||||
//- True if range is empty (zero-sized)
|
||||
bool empty() const noexcept { return !size_; }
|
||||
|
||||
//- True if range has size greater than zero
|
||||
bool good() const noexcept { return (size_ > 0); }
|
||||
|
||||
//- The (inclusive) lower value of the range.
|
||||
constexpr label min() const noexcept { return start_; }
|
||||
//- The size of the range
|
||||
label size() const noexcept { return size_; }
|
||||
|
||||
//- Non-const access to size of the range
|
||||
label& size() noexcept { return size_; }
|
||||
|
||||
//- The (inclusive) lower value of the range
|
||||
label start() const noexcept { return start_; }
|
||||
|
||||
//- Non-const access to start of the range
|
||||
label& start() noexcept { return start_; }
|
||||
|
||||
//- The stride for the range
|
||||
label stride() const noexcept { return stride_; }
|
||||
|
||||
//- Non-const access to the stride
|
||||
label& stride() noexcept { return stride_; }
|
||||
|
||||
//- The (inclusive) lower value of the range,
|
||||
//- same as start()
|
||||
label min() const noexcept { return start_; }
|
||||
|
||||
//- The (inclusive) upper value of the range.
|
||||
//- Ill-defined for an empty range
|
||||
@ -195,7 +205,7 @@ public:
|
||||
class indexer
|
||||
{
|
||||
//- The stride when indexing
|
||||
const label stride_;
|
||||
label stride_;
|
||||
|
||||
//- The global value
|
||||
label value_;
|
||||
|
Loading…
Reference in New Issue
Block a user