diff --git a/applications/test/labelRanges/Test-labelRanges.C b/applications/test/labelRanges/Test-labelRanges.C index fc3b7050c6..55202c1b49 100644 --- a/applications/test/labelRanges/Test-labelRanges.C +++ b/applications/test/labelRanges/Test-labelRanges.C @@ -37,9 +37,7 @@ using namespace Foam; void printInfo(const labelRange& range) { - Info<< "first " << range.first() << nl - << "last " << range.last() << nl - << "min " << range.min() << nl + Info<< "min " << range.min() << nl << "max " << range.max() << nl << "end " << range.end_value() << nl << "begin/end " << *range.cbegin() << ' ' << *range.cend() << nl; diff --git a/applications/test/sliceRange/Test-sliceRange.C b/applications/test/sliceRange/Test-sliceRange.C index 7a0c0abc61..b3f4f8df8b 100644 --- a/applications/test/sliceRange/Test-sliceRange.C +++ b/applications/test/sliceRange/Test-sliceRange.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -47,10 +47,10 @@ void printInfo(const sliceCoeffs& coeffs) Info<< nl << "coeffs: " << coeffs << nl - << "range: " << range << nl - << "first: " << range.first() << nl + << "range: " << range << nl + << "min: " << range.min() << nl << "*begin " << *range.begin() << nl - << "last: " << range.last() << nl + << "max: " << range.max() << nl << "*end " << *range.end() << nl << "values: " << flatOutput(range.labels()) << nl; diff --git a/src/OpenFOAM/primitives/predicates/scalar/scalarPredicates.C b/src/OpenFOAM/primitives/predicates/scalar/scalarPredicates.C index ea82157989..dd6501ac7a 100644 --- a/src/OpenFOAM/primitives/predicates/scalar/scalarPredicates.C +++ b/src/OpenFOAM/primitives/predicates/scalar/scalarPredicates.C @@ -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. @@ -109,7 +109,7 @@ namespace Foam { for (const auto& entry : entries) { - if (!Foam::predicates::scalars::opNames.found(get0(entry))) + if (!Foam::predicates::scalars::opNames.contains(get0(entry))) { return true; } @@ -135,7 +135,7 @@ namespace Foam for (const auto& entry : entries) { - if (!Foam::predicates::scalars::opNames.found(get0(entry))) + if (!Foam::predicates::scalars::opNames.contains(get0(entry))) { badIndices.insert(idx); } @@ -150,7 +150,7 @@ namespace Foam idx = 0; for (const auto& entry : entries) { - const bool bad = badIndices.found(idx); + const bool bad = badIndices.contains(idx); ++idx; if (bad) diff --git a/src/OpenFOAM/primitives/predicates/scalar/scalarPredicates.H b/src/OpenFOAM/primitives/predicates/scalar/scalarPredicates.H index 3107efe1c4..cc6cabda09 100644 --- a/src/OpenFOAM/primitives/predicates/scalar/scalarPredicates.H +++ b/src/OpenFOAM/primitives/predicates/scalar/scalarPredicates.H @@ -282,31 +282,31 @@ public: // \return position in list or -1 if not found. label rfind(const scalar value, label pos = -1) const; - //- True if the value matches in the list. + //- Matches \em any condition in the list after the offset position. // Linear search from start pos until the end of the list. // Any occurrences before the start pos are ignored. - // \return true if found. + // + // \return True if the value matches any condition in the (sub)list. inline bool contains(const scalar value, label pos = 0) const; - //- Match \em any condition in the list. + //- Matches \em any condition in the list. // // \return True if the value matches any condition in the list. inline bool match(const scalar value) const; - //- Match \em any condition in the list. + //- Matches \em any condition in the list. // // \return True if the value matches any condition in the list. inline bool matchAny(const scalar value) const; - //- Match \em all conditions in the list. + //- Matches \em all conditions in the list. // // \return True if the value matches all conditions in the list. inline bool matchAll(const scalar value) const; //- Extract list indices for all matches. // - // \return The locations (indices) in the input list where match() - // is true + // \return The locations (indices) of the predicates that match inline labelList matching(const scalar value) const; //- Extract list indices for all matches. @@ -325,7 +325,7 @@ public: // Member Operators //- Identical to contains(), match(), for use as a predicate. - inline bool operator()(const scalar value) const; + bool operator()(const scalar value) const { return matchAny(value); } // Housekeeping diff --git a/src/OpenFOAM/primitives/predicates/scalar/scalarPredicatesI.H b/src/OpenFOAM/primitives/predicates/scalar/scalarPredicatesI.H index 3f6fcf4b9e..09b0d10443 100644 --- a/src/OpenFOAM/primitives/predicates/scalar/scalarPredicatesI.H +++ b/src/OpenFOAM/primitives/predicates/scalar/scalarPredicatesI.H @@ -72,15 +72,15 @@ inline bool Foam::predicates::scalars::contains inline bool Foam::predicates::scalars::match(const scalar value) const { - return this->matchAny(value); + return matchAny(value); } inline bool Foam::predicates::scalars::matchAny(const scalar value) const { - for (const unary& test : *this) + for (const unary& pred : *this) { - if (test(value)) + if (pred(value)) { return true; } @@ -92,9 +92,9 @@ inline bool Foam::predicates::scalars::matchAny(const scalar value) const inline bool Foam::predicates::scalars::matchAll(const scalar value) const { - for (const unary& test : *this) + for (const unary& pred : *this) { - if (!test(value)) + if (!pred(value)) { return false; } @@ -112,9 +112,9 @@ inline Foam::labelList Foam::predicates::scalars::matching labelList indices(this->size()); label i = 0, count = 0; - for (const unary& test : *this) + for (const unary& pred : *this) { - if (test(value)) + if (pred(value)) { indices[count] = i; ++count; @@ -140,7 +140,7 @@ inline Foam::labelList Foam::predicates::scalars::matching label count = 0; for (label i=0; i < len; ++i) { - if (match(input[i]) ? !invert : invert) + if (matchAny(input[i]) ? !invert : invert) { indices[count] = i; ++count; @@ -152,12 +152,4 @@ inline Foam::labelList Foam::predicates::scalars::matching } -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -inline bool Foam::predicates::scalars::operator()(const scalar value) const -{ - return this->found(value); -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/ranges/IntRange/IntRange.H b/src/OpenFOAM/primitives/ranges/IntRange/IntRange.H index 28502905b4..9f1eeddaa1 100644 --- a/src/OpenFOAM/primitives/ranges/IntRange/IntRange.H +++ b/src/OpenFOAM/primitives/ranges/IntRange/IntRange.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -172,19 +172,13 @@ public: //- Non-const access to start of the range IntType& start() noexcept { return start_; } - //- The (inclusive) lower value of the range. Same as start() - IntType first() const noexcept { return start_; } - - //- The (inclusive) upper value of the range - IntType last() const noexcept { return (start_ + (size_ - 1)); } - //- The (inclusive) lower value of the range, - //- same as first(), start(), begin_value() - IntType min() const noexcept { return start(); } + //- same as start(), begin_value() + IntType min() const noexcept { return start_; } //- The (inclusive) upper value of the range, - //- same as last(), rbegin_value() - IntType max() const noexcept { return last(); } + //- same as rbegin_value(). Ill-defined for an empty range + IntType max() const noexcept { return (start_ + (size_ - 1)); } // Edit @@ -252,13 +246,13 @@ public: // Iterator ranges - //- The value at the beginning of the range - same as first(), start() + //- The value at the beginning of the range - same as min(), start() inline IntType begin_value() const noexcept; //- The value 1 beyond the end of the range. inline IntType end_value() const noexcept; - //- The last value of the range. + //- The max value of the range. inline IntType rbegin_value() const noexcept; //- The value 1 before the begin of range @@ -563,7 +557,7 @@ inline constexpr bool operator== const IntRange& b ) noexcept { - return (a.first() == b.first() && a.size() == b.size()); + return (a.start() == b.start() && a.size() == b.size()); } @@ -578,10 +572,10 @@ inline constexpr bool operator< { return ( - a.first() < b.first() + a.start() < b.start() || ( - !(b.first() < a.first()) + !(b.start() < a.start()) && a.size() < b.size() ) ); diff --git a/src/OpenFOAM/primitives/ranges/IntRange/IntRanges.C b/src/OpenFOAM/primitives/ranges/IntRange/IntRanges.C index eb67f57372..0b69add7d6 100644 --- a/src/OpenFOAM/primitives/ranges/IntRange/IntRanges.C +++ b/src/OpenFOAM/primitives/ranges/IntRange/IntRanges.C @@ -36,42 +36,41 @@ License namespace Foam { - template - inline static List