diff --git a/applications/test/FixedList/Test-FixedList.C b/applications/test/FixedList/Test-FixedList.C index 0a2c56a229..6e8210c825 100644 --- a/applications/test/FixedList/Test-FixedList.C +++ b/applications/test/FixedList/Test-FixedList.C @@ -33,7 +33,6 @@ See also \*---------------------------------------------------------------------------*/ #include "argList.H" -#include "IOstreams.H" #include "FixedList.H" #include "IFstream.H" #include "OFstream.H" @@ -64,6 +63,15 @@ int main(int argc, char *argv[]) Info<< "list2:" << list2 << " hash:" << FixedList::Hash<>()(list2) << endl; + // Using FixedList for content too + { + List> twolists{list, list2}; + Info<<"List of FixedList: " << flatOutput(twolists) << endl; + sort(twolists); + // outer-sort only + Info<<"sorted FixedList : " << flatOutput(twolists) << endl; + } + Info<< "list: " << list << nl << "list2: " << list2 << endl; list.swap(list2); diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C b/src/OpenFOAM/containers/Lists/FixedList/FixedList.C index 6b919cf037..8a3b5d078b 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.C @@ -70,31 +70,24 @@ bool Foam::FixedList::operator!=(const FixedList& a) const template bool Foam::FixedList::operator<(const FixedList& a) const { - for - ( - const_iterator vi = cbegin(), ai = a.cbegin(); - vi < cend() && ai < a.cend(); - vi++, ai++ - ) + const T* const __restrict__ ptr1 = this->begin(); + const T* const __restrict__ ptr2 = a.begin(); + + for (unsigned i=0; i *ai) + else if (ptr1[i] > ptr2[i]) { return false; } } - if (Size < a.Size) - { - return true; - } - else - { - return false; - } + // Contents look to be identical. + // The sizes are identical by definition (template parameter) + return false; } diff --git a/src/OpenFOAM/containers/Lists/UList/UList.C b/src/OpenFOAM/containers/Lists/UList/UList.C index 320b22f68f..b36eae19e5 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.C +++ b/src/OpenFOAM/containers/Lists/UList/UList.C @@ -196,14 +196,8 @@ bool Foam::UList::operator<(const UList& a) const } } - if (this->size_ < a.size_) - { - return true; - } - else - { - return false; - } + // Contents look to be identical, or lists have different sizes + return (this->size_ < a.size_); }