mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: relocate sortedOrder from ListOps.H to List.H
- commonly used, only depends on routines defined in UList (don't need the rest of ListOps for it). ENH: implement boolList::operator() const - allows use as a predicate functor, as per bitSet and labelHashSet GIT: combine SubList, UList into List directory (intertwined concepts) STYLE: default initialize DynamicList instead of with size 0
This commit is contained in:
@ -157,18 +157,34 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
boolList list2(5, true);
|
boolList list2(5, true);
|
||||||
list2.unset(2);
|
list2.unset(2);
|
||||||
|
list2.unset(3);
|
||||||
|
|
||||||
Info<< "Test wrapper idea" << nl;
|
Info<< "Test wrapper idea" << nl;
|
||||||
|
|
||||||
bitSetOrBoolList wrapper(list2);
|
bitSetOrBoolList wrapper(list2);
|
||||||
|
|
||||||
if (wrapper.test(1))
|
// Use predicate, or test() method
|
||||||
|
|
||||||
|
if (list2(1))
|
||||||
{
|
{
|
||||||
Info<< "1 is on" << nl;
|
Info<< "1 is on (original)" << nl;
|
||||||
}
|
}
|
||||||
if (!wrapper.test(2))
|
if (!list2(2))
|
||||||
{
|
{
|
||||||
Info<< "2 is off" << nl;
|
Info<< "2 is off (original)" << nl;
|
||||||
|
}
|
||||||
|
if (!list2(100))
|
||||||
|
{
|
||||||
|
Info<< "100 is off (original)" << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wrapper(1))
|
||||||
|
{
|
||||||
|
Info<< "1 is on (wrapped)" << nl;
|
||||||
|
}
|
||||||
|
if (!wrapper(2))
|
||||||
|
{
|
||||||
|
Info<< "2 is off (wrapped)" << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2020 OpenCFD Ltd.
|
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -32,8 +32,8 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef bitSetOrBoolList_H
|
#ifndef Foam_bitSetOrBoolList_H
|
||||||
#define bitSetOrBoolList_H
|
#define Foam_bitSetOrBoolList_H
|
||||||
|
|
||||||
#include "bitSet.H"
|
#include "bitSet.H"
|
||||||
#include "boolList.H"
|
#include "boolList.H"
|
||||||
@ -88,6 +88,13 @@ public:
|
|||||||
{
|
{
|
||||||
return bits_.test(i) || bools_.test(i);
|
return bits_.test(i) || bools_.test(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Test predicate
|
||||||
|
bool operator()(const label i) const
|
||||||
|
{
|
||||||
|
// Can also use test(i) etc...
|
||||||
|
return bits_(i) || bools_(i);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -41,8 +41,8 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef disabledBoolList_H
|
#ifndef Foam_disabledBoolList_H
|
||||||
#define disabledBoolList_H
|
#define Foam_disabledBoolList_H
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class disabledBoolList Declaration
|
Class disabledBoolList Declaration
|
||||||
@ -60,6 +60,9 @@ struct disabledBoolList
|
|||||||
bool test(int) const { return true; }
|
bool test(int) const { return true; }
|
||||||
|
|
||||||
void set(bool) {}
|
void set(bool) {}
|
||||||
|
|
||||||
|
// Perhaps not?
|
||||||
|
/// bool operator()(const label i) const { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -31,7 +31,7 @@ Description
|
|||||||
#include "string.H"
|
#include "string.H"
|
||||||
#include "macros.H"
|
#include "macros.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "UList.H"
|
#include "List.H"
|
||||||
#include "HashSet.H"
|
#include "HashSet.H"
|
||||||
|
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|||||||
@ -163,9 +163,8 @@ void Foam::conformalVoronoiMesh::calcTetMesh
|
|||||||
|
|
||||||
label nPatches = patchNames.size();
|
label nPatches = patchNames.size();
|
||||||
|
|
||||||
List<DynamicList<face>> patchFaces(nPatches, DynamicList<face>(0));
|
List<DynamicList<face>> patchFaces(nPatches);
|
||||||
|
List<DynamicList<label>> patchOwners(nPatches);
|
||||||
List<DynamicList<label>> patchOwners(nPatches, DynamicList<label>(0));
|
|
||||||
|
|
||||||
faces.setSize(number_of_finite_facets());
|
faces.setSize(number_of_finite_facets());
|
||||||
|
|
||||||
@ -1711,12 +1710,11 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
|
|||||||
patchDicts[patchi].getOrDefault<label>("neighbProcNo", -1);
|
patchDicts[patchi].getOrDefault<label>("neighbProcNo", -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DynamicList<face>> patchFaces(nPatches, DynamicList<face>(0));
|
List<DynamicList<face>> patchFaces(nPatches);
|
||||||
List<DynamicList<label>> patchOwners(nPatches, DynamicList<label>(0));
|
List<DynamicList<label>> patchOwners(nPatches);
|
||||||
// Per patch face the index of the slave node of the point pair
|
// Per patch face the index of the slave node of the point pair
|
||||||
List<DynamicList<label>> patchPPSlaves(nPatches, DynamicList<label>(0));
|
List<DynamicList<label>> patchPPSlaves(nPatches);
|
||||||
|
List<DynamicList<bool>> indirectPatchFace(nPatches);
|
||||||
List<DynamicList<bool>> indirectPatchFace(nPatches, DynamicList<bool>(0));
|
|
||||||
|
|
||||||
|
|
||||||
faces.setSize(number_of_finite_edges());
|
faces.setSize(number_of_finite_edges());
|
||||||
|
|||||||
@ -32,8 +32,8 @@ License
|
|||||||
#include "JobInfo.H"
|
#include "JobInfo.H"
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
#include "List.H"
|
||||||
#include "Switch.H"
|
#include "Switch.H"
|
||||||
#include "UList.H"
|
|
||||||
|
|
||||||
#include <float.h> // For *fp functions
|
#include <float.h> // For *fp functions
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|||||||
@ -31,8 +31,8 @@ License
|
|||||||
#include "JobInfo.H"
|
#include "JobInfo.H"
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
#include "List.H"
|
||||||
#include "Switch.H"
|
#include "Switch.H"
|
||||||
#include "UList.H"
|
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "ListOps.H"
|
#include "ListOps.H" // For identity
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -636,4 +636,52 @@ void Foam::List<T>::operator=(SLList<T>&& list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
Foam::labelList Foam::sortedOrder
|
||||||
|
(
|
||||||
|
const UList<T>& list
|
||||||
|
)
|
||||||
|
{
|
||||||
|
labelList order;
|
||||||
|
Foam::sortedOrder(list, order, typename UList<T>::less(list));
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::sortedOrder
|
||||||
|
(
|
||||||
|
const UList<T>& list,
|
||||||
|
labelList& order
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Foam::sortedOrder(list, order, typename UList<T>::less(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class ListComparePredicate>
|
||||||
|
void Foam::sortedOrder
|
||||||
|
(
|
||||||
|
const UList<T>& list,
|
||||||
|
labelList& order,
|
||||||
|
const ListComparePredicate& comp
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// List lengths must be identical. Old content is overwritten
|
||||||
|
order.resize_nocopy(list.size());
|
||||||
|
|
||||||
|
// Same as std::iota and ListOps::identity
|
||||||
|
label value = 0;
|
||||||
|
for (label& item : order)
|
||||||
|
{
|
||||||
|
item = value;
|
||||||
|
++value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Foam::stableSort(order, comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -373,10 +373,27 @@ Istream& operator>>(Istream& is, List<T>& list)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//- Create identity map of the given length with (map[i] == i)
|
//- Return an identity map of the given length with (map[i] == i)
|
||||||
// Optionally with an alternative start index, so that (map[i] == i+start)
|
// Optionally with an alternative start index, so that (map[i] == i+start)
|
||||||
labelList identity(const label len, label start=0);
|
labelList identity(const label len, label start=0);
|
||||||
|
|
||||||
|
//- Return the (stable) sort order for the list
|
||||||
|
template<class T>
|
||||||
|
labelList sortedOrder(const UList<T>& input);
|
||||||
|
|
||||||
|
//- Generate the (stable) sort order for the list
|
||||||
|
template<class T>
|
||||||
|
void sortedOrder(const UList<T>& input, labelList& order);
|
||||||
|
|
||||||
|
//- Sort using specified list compare predicate
|
||||||
|
template<class T, class ListComparePredicate>
|
||||||
|
void sortedOrder
|
||||||
|
(
|
||||||
|
const UList<T>& input,
|
||||||
|
labelList& order,
|
||||||
|
const ListComparePredicate& comp
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -39,11 +39,10 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef SubList_H
|
#ifndef Foam_SubList_H
|
||||||
#define SubList_H
|
#define Foam_SubList_H
|
||||||
|
|
||||||
#include "List.H"
|
#include "List.H"
|
||||||
#include "FixedList.H"
|
|
||||||
#include "labelRange.H"
|
#include "labelRange.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -52,6 +51,7 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Forward Declarations
|
// Forward Declarations
|
||||||
|
template<class T, unsigned N> class FixedList;
|
||||||
template<class T> class SubList;
|
template<class T> class SubList;
|
||||||
|
|
||||||
// Common list types
|
// Common list types
|
||||||
@ -26,6 +26,8 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "FixedList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -257,41 +257,6 @@ Foam::label Foam::UList<T>::rfind(const T& val, label pos) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void Foam::sort(UList<T>& a)
|
|
||||||
{
|
|
||||||
std::sort(a.begin(), a.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T, class Compare>
|
|
||||||
void Foam::sort(UList<T>& a, const Compare& comp)
|
|
||||||
{
|
|
||||||
std::sort(a.begin(), a.end(), comp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void Foam::stableSort(UList<T>& a)
|
|
||||||
{
|
|
||||||
std::stable_sort(a.begin(), a.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T, class Compare>
|
|
||||||
void Foam::stableSort(UList<T>& a, const Compare& comp)
|
|
||||||
{
|
|
||||||
std::stable_sort(a.begin(), a.end(), comp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void Foam::shuffle(UList<T>& a)
|
|
||||||
{
|
|
||||||
std::shuffle(a.begin(), a.end(), std::default_random_engine());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -371,4 +336,41 @@ bool Foam::UList<T>::operator>=(const UList<T>& list) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::sort(UList<T>& list)
|
||||||
|
{
|
||||||
|
std::sort(list.begin(), list.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class Compare>
|
||||||
|
void Foam::sort(UList<T>& list, const Compare& comp)
|
||||||
|
{
|
||||||
|
std::sort(list.begin(), list.end(), comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::stableSort(UList<T>& list)
|
||||||
|
{
|
||||||
|
std::stable_sort(list.begin(), list.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class Compare>
|
||||||
|
void Foam::stableSort(UList<T>& list, const Compare& comp)
|
||||||
|
{
|
||||||
|
std::stable_sort(list.begin(), list.end(), comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Foam::shuffle(UList<T>& list)
|
||||||
|
{
|
||||||
|
std::shuffle(list.begin(), list.end(), std::default_random_engine());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -74,6 +74,7 @@ class labelRange;
|
|||||||
template<class T> class List;
|
template<class T> class List;
|
||||||
template<class T> class SubList;
|
template<class T> class SubList;
|
||||||
template<class T> class UList;
|
template<class T> class UList;
|
||||||
|
template<class T> class IndirectList;
|
||||||
template<class T, class Addr> class IndirectListBase;
|
template<class T, class Addr> class IndirectListBase;
|
||||||
|
|
||||||
template<class T> Istream& operator>>(Istream&, UList<T>&);
|
template<class T> Istream& operator>>(Istream&, UList<T>&);
|
||||||
@ -510,9 +511,19 @@ public:
|
|||||||
|
|
||||||
// Special Methods
|
// Special Methods
|
||||||
|
|
||||||
//- A bitSet::test() method for a list of bool
|
//- Test \c bool value at specified position,
|
||||||
//
|
//- always false for out-of-range access. Same as test().
|
||||||
// \return The element value, or false for out-of-range access
|
// \note Predicate definition as per bitSet, HashSet
|
||||||
|
template<class TypeT = T>
|
||||||
|
typename std::enable_if<std::is_same<bool, TypeT>::value, bool>::type
|
||||||
|
inline operator()(const label i) const
|
||||||
|
{
|
||||||
|
return (i >= 0 && i < size_ && v_[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Test \c bool value at specified position,
|
||||||
|
//- always false for out-of-range access.
|
||||||
|
// \note Method name compatibility with bitSet, HashSet
|
||||||
template<class TypeT = T>
|
template<class TypeT = T>
|
||||||
typename std::enable_if<std::is_same<bool, TypeT>::value, bool>::type
|
typename std::enable_if<std::is_same<bool, TypeT>::value, bool>::type
|
||||||
inline test(const label i) const
|
inline test(const label i) const
|
||||||
@ -520,9 +531,9 @@ public:
|
|||||||
return (i >= 0 && i < size_ && v_[i]);
|
return (i >= 0 && i < size_ && v_[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- A bitSet::get() method for a list of bool
|
//- Return \c bool value at specified position,
|
||||||
//
|
//- always false for out-of-range access.
|
||||||
// \return The element value, or false for out-of-range access
|
// \note Method name compatibility with bitSet
|
||||||
template<class TypeT = T>
|
template<class TypeT = T>
|
||||||
typename std::enable_if<std::is_same<bool, TypeT>::value, bool>::type
|
typename std::enable_if<std::is_same<bool, TypeT>::value, bool>::type
|
||||||
inline get(const label i) const
|
inline get(const label i) const
|
||||||
@ -530,9 +541,10 @@ public:
|
|||||||
return (i >= 0 && i < size_ && v_[i]);
|
return (i >= 0 && i < size_ && v_[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- A bitSet::unset() method for a list of bool
|
//- Unset the \c bool entry at specified position,
|
||||||
//
|
//- always false for out-of-range access.
|
||||||
// \return True if value changed and was not out-of-range
|
// \return True if value changed and was not out-of-range
|
||||||
|
// \note Method name compatibility with bitSet
|
||||||
template<class TypeT = T>
|
template<class TypeT = T>
|
||||||
typename std::enable_if<std::is_same<bool, TypeT>::value, bool>::type
|
typename std::enable_if<std::is_same<bool, TypeT>::value, bool>::type
|
||||||
inline unset(const label i)
|
inline unset(const label i)
|
||||||
@ -624,26 +636,31 @@ Ostream& operator<<(Ostream& os, const std::vector<T>& list);
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//- Sort the list
|
||||||
template<class T>
|
template<class T>
|
||||||
void sort(UList<T>& a);
|
void sort(UList<T>& list);
|
||||||
|
|
||||||
|
//- Sort the list with the specified comparator
|
||||||
template<class T, class Compare>
|
template<class T, class Compare>
|
||||||
void sort(UList<T>& a, const Compare& comp);
|
void sort(UList<T>& list, const Compare& comp);
|
||||||
|
|
||||||
|
//- Stable sort the list
|
||||||
template<class T>
|
template<class T>
|
||||||
void stableSort(UList<T>& a);
|
void stableSort(UList<T>& list);
|
||||||
|
|
||||||
|
//- Stable sort the list with the specified comparator
|
||||||
template<class T, class Compare>
|
template<class T, class Compare>
|
||||||
void stableSort(UList<T>& a, const Compare& comp);
|
void stableSort(UList<T>& list, const Compare& comp);
|
||||||
|
|
||||||
|
//- Randomise the list order
|
||||||
template<class T>
|
template<class T>
|
||||||
void shuffle(UList<T>& a);
|
void shuffle(UList<T>& list);
|
||||||
|
|
||||||
// Reverse the first n elements of the list
|
//- Reverse the first n elements of the list
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void reverse(UList<T>& list, const label n);
|
inline void reverse(UList<T>& list, const label n);
|
||||||
|
|
||||||
// Reverse all the elements of the list
|
//- Reverse all elements of the list
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void reverse(UList<T>& list);
|
inline void reverse(UList<T>& list);
|
||||||
|
|
||||||
@ -448,7 +448,9 @@ inline void Foam::UList<T>::swap(UList<T>& list)
|
|||||||
template<class T>
|
template<class T>
|
||||||
inline void Foam::reverse(UList<T>& list, const label n)
|
inline void Foam::reverse(UList<T>& list, const label n)
|
||||||
{
|
{
|
||||||
for (label i=0; i<n/2; ++i)
|
const label nBy2 = n/2;
|
||||||
|
|
||||||
|
for (label i = 0; i < nBy2; ++i)
|
||||||
{
|
{
|
||||||
Foam::Swap(list[i], list[n-1-i]);
|
Foam::Swap(list[i], list[n-1-i]);
|
||||||
}
|
}
|
||||||
@ -458,7 +460,7 @@ inline void Foam::reverse(UList<T>& list, const label n)
|
|||||||
template<class T>
|
template<class T>
|
||||||
inline void Foam::reverse(UList<T>& list)
|
inline void Foam::reverse(UList<T>& list)
|
||||||
{
|
{
|
||||||
reverse(list, list.size());
|
Foam::reverse(list, list.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -48,6 +48,7 @@ SourceFiles
|
|||||||
#include "FlatOutput.H"
|
#include "FlatOutput.H"
|
||||||
#include "labelPair.H"
|
#include "labelPair.H"
|
||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
|
#include "IndirectList.H"
|
||||||
#include "HashSet.H"
|
#include "HashSet.H"
|
||||||
#include "Map.H"
|
#include "Map.H"
|
||||||
#include "bitSet.H"
|
#include "bitSet.H"
|
||||||
@ -178,24 +179,6 @@ template<class Container>
|
|||||||
label inplaceMapValue(const Map<label>& mapper, Container& input);
|
label inplaceMapValue(const Map<label>& mapper, Container& input);
|
||||||
|
|
||||||
|
|
||||||
//- Return the (stable) sort order for the list
|
|
||||||
template<class T>
|
|
||||||
labelList sortedOrder(const UList<T>& input);
|
|
||||||
|
|
||||||
//- Generate the (stable) sort order for the list
|
|
||||||
template<class T>
|
|
||||||
void sortedOrder(const UList<T>& input, labelList& order);
|
|
||||||
|
|
||||||
//- Sort using specified list compare predicate
|
|
||||||
template<class T, class ListComparePredicate>
|
|
||||||
void sortedOrder
|
|
||||||
(
|
|
||||||
const UList<T>& input,
|
|
||||||
labelList& order,
|
|
||||||
const ListComparePredicate& comp
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Return (sorted) indices corresponding to duplicate list values
|
//- Return (sorted) indices corresponding to duplicate list values
|
||||||
template<class T>
|
template<class T>
|
||||||
labelList duplicateOrder(const UList<T>& input);
|
labelList duplicateOrder(const UList<T>& input);
|
||||||
@ -320,7 +303,7 @@ void inplaceSubset
|
|||||||
|
|
||||||
//- Copy a subset of the input list when predicate is true.
|
//- Copy a subset of the input list when predicate is true.
|
||||||
//
|
//
|
||||||
// \param[in,out] input the list input values.
|
// \param[in] input the list input values.
|
||||||
// \param[in] pred the selection predicate
|
// \param[in] pred the selection predicate
|
||||||
// \param[in] invert set as true to invert the selection logic
|
// \param[in] invert set as true to invert the selection logic
|
||||||
template<class T, class UnaryPredicate>
|
template<class T, class UnaryPredicate>
|
||||||
|
|||||||
@ -321,46 +321,6 @@ Foam::label Foam::inplaceMapValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
Foam::labelList Foam::sortedOrder
|
|
||||||
(
|
|
||||||
const UList<T>& input
|
|
||||||
)
|
|
||||||
{
|
|
||||||
labelList order;
|
|
||||||
sortedOrder(input, order, typename UList<T>::less(input));
|
|
||||||
return order;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
void Foam::sortedOrder
|
|
||||||
(
|
|
||||||
const UList<T>& input,
|
|
||||||
labelList& order
|
|
||||||
)
|
|
||||||
{
|
|
||||||
sortedOrder(input, order, typename UList<T>::less(input));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T, class ListComparePredicate>
|
|
||||||
void Foam::sortedOrder
|
|
||||||
(
|
|
||||||
const UList<T>& input,
|
|
||||||
labelList& order,
|
|
||||||
const ListComparePredicate& comp
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// List lengths must be identical. Old content is overwritten
|
|
||||||
order.resize_nocopy(input.size());
|
|
||||||
|
|
||||||
ListOps::identity(order);
|
|
||||||
|
|
||||||
Foam::stableSort(order, comp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Foam::labelList Foam::duplicateOrder
|
Foam::labelList Foam::duplicateOrder
|
||||||
(
|
(
|
||||||
@ -398,7 +358,7 @@ void Foam::duplicateOrder
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sortedOrder(input, order, comp);
|
Foam::sortedOrder(input, order, comp);
|
||||||
|
|
||||||
const label last = (order.size()-1);
|
const label last = (order.size()-1);
|
||||||
label count = 0;
|
label count = 0;
|
||||||
@ -445,7 +405,7 @@ void Foam::uniqueOrder
|
|||||||
const ListComparePredicate& comp
|
const ListComparePredicate& comp
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
sortedOrder(input, order, comp);
|
Foam::sortedOrder(input, order, comp);
|
||||||
|
|
||||||
if (order.size() > 1)
|
if (order.size() > 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -26,7 +26,7 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "ListOps.H"
|
#include "ListOps.H" // For identity
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,6 @@ License
|
|||||||
#include "CircularBuffer.H"
|
#include "CircularBuffer.H"
|
||||||
#include "CompactListList.H"
|
#include "CompactListList.H"
|
||||||
#include "DynamicList.H"
|
#include "DynamicList.H"
|
||||||
#include "ListOps.H" // sortedOrder
|
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -27,7 +27,7 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "IOobject.H"
|
#include "IOobject.H"
|
||||||
#include "UList.H"
|
#include "List.H"
|
||||||
#include "hexRef8Data.H"
|
#include "hexRef8Data.H"
|
||||||
#include "mapPolyMesh.H"
|
#include "mapPolyMesh.H"
|
||||||
#include "mapDistributePolyMesh.H"
|
#include "mapDistributePolyMesh.H"
|
||||||
|
|||||||
@ -1048,8 +1048,8 @@ Foam::autoPtr<Foam::refinementHistory> Foam::refinementHistory::clone
|
|||||||
new refinementHistory
|
new refinementHistory
|
||||||
(
|
(
|
||||||
io,
|
io,
|
||||||
DynamicList<splitCell8>(0),
|
List<splitCell8>(),
|
||||||
labelList(0),
|
labelList(),
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -28,7 +28,7 @@ License
|
|||||||
|
|
||||||
#include "ensightFile.H"
|
#include "ensightFile.H"
|
||||||
#include "error.H"
|
#include "error.H"
|
||||||
#include "UList.H"
|
#include "List.H"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,7 @@ SourceFiles
|
|||||||
#include "uint64.H"
|
#include "uint64.H"
|
||||||
#include "direction.H"
|
#include "direction.H"
|
||||||
#include "word.H"
|
#include "word.H"
|
||||||
#include "UList.H"
|
#include "List.H"
|
||||||
#include "DynamicList.H"
|
#include "DynamicList.H"
|
||||||
#include "foamVtkCore.H"
|
#include "foamVtkCore.H"
|
||||||
#include "foamVtkPTraits.H"
|
#include "foamVtkPTraits.H"
|
||||||
|
|||||||
@ -41,7 +41,6 @@ License
|
|||||||
#include "CompactListList.H"
|
#include "CompactListList.H"
|
||||||
#include "objectMap.H"
|
#include "objectMap.H"
|
||||||
#include "processorPolyPatch.H"
|
#include "processorPolyPatch.H"
|
||||||
#include "ListOps.H" // sortedOrder
|
|
||||||
#include "mapPolyMesh.H"
|
#include "mapPolyMesh.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|||||||
Reference in New Issue
Block a user