47 const label len = this->size();
50 for (label i=0; i < len; ++i)
71 const label len = this->size();
73 if (oldToNew.size() != len)
76 <<
"Size of map (" << oldToNew.size()
77 <<
") not equal to list size (" << len
78 <<
") for type " <<
typeid(
T).
name() << nl
82 Detail::PtrListDetail<T> newList(len);
84 for (label i = 0; i < len; ++i)
86 const label newIdx = oldToNew[i];
88 if (newIdx < 0 || newIdx >= len)
91 <<
"Illegal index " << newIdx <<
nl
92 <<
"Valid indices are [0," << len <<
") for type "
100 <<
"reorder map is not unique; element " << newIdx
101 <<
" already used for type " <<
typeid(
T).
name()
102 <<
abort(FatalError);
104 newList[newIdx] = ptrs_[i];
110 newList.checkNonNull();
121 const label len = this->size();
123 if (order.
size() != len)
126 <<
"Size of map (" << order.
size()
127 <<
") not equal to list size (" << len
128 <<
") for type " <<
typeid(
T).
name() <<
nl
132 Detail::PtrListDetail<T> newList(len);
133 Detail::PtrListDetail<T> guard(len);
135 for (label i = 0; i < len; ++i)
137 const label oldIdx = order[i];
139 if (oldIdx < 0 || oldIdx >= len)
142 <<
"Illegal index " << oldIdx << nl
143 <<
"Valid indices are [0," << len <<
") for type "
144 <<
typeid(
T).
name() << nl
145 << abort(FatalError);
151 <<
"order map is not unique; element " << oldIdx
152 <<
" already used for type " <<
typeid(
T).
name()
153 <<
abort(FatalError);
156 guard[oldIdx] = ptrs_[oldIdx];
157 newList[i] = ptrs_[oldIdx];
163 newList.checkNonNull();
176 return ptrs_.printAddresses(
os);
187 return ptrs_.
write(
os, trimNull);
194 return list.writeList(
os,
false);
208 [](
const T*
const a,
const T*
const b) ->
bool
210 return (a && b) ? (*a < *b) : !b;
216template<
class T,
class Compare>
217void Foam::sort(UPtrList<T>& list,
const Compare& comp)
223 typename UPtrList<T>::template value_compare<Compare>(comp)
A rudimentary list of pointers used for PtrList, UPtrList, etc. This class is considered implementati...
void checkNonNull() const
FatalError if any null exists in the list.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
void size(const label n)
Older name for setAddressableSize.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
T ** begin_ptr() noexcept
Iterator to begin of raw pointers traversal (use with caution).
void reorder(const labelUList &oldToNew, const bool check=false)
Reorder elements. Reordering must be unique (ie, shuffle).
Ostream & writeList(Ostream &os, const bool trimNull=false) const
Write UPtrList to Ostream, optionally ignoring null entries.
Ostream & printAddresses(Ostream &os) const
Print pointer addresses to Ostream (debugging only).
void sortOrder(const labelUList &order, const bool check=false)
Reorder elements according to new order mapping (newToOld). Reordering must be unique (ie,...
T ** end_ptr() noexcept
Iterator beyond end of raw pointers traversal (use with caution).
label size() const noexcept
The number of entries in the list.
constexpr UPtrList() noexcept=default
Default construct.
label squeezeNull()
Squeeze out nullptr entries in the list of pointers after which any null pointers will be at the end ...
Detail::PtrListDetail< T > ptrs_
The list of pointers.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
static void check(const int retVal, const char *what)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
void sort(UList< T > &list)
Sort the list.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
UList< label > labelUList
A UList of labels.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
constexpr char nl
The newline '\n' character (0x0a).