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 " << error::demangle<T>() <<
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 " 93 << error::demangle<T>() <<
nl 100 <<
"reorder map is not unique; element " << newIdx
101 <<
" already used for type " 102 << error::demangle<T>() <<
nl 105 newList[newIdx] = ptrs_[i];
111 newList.checkNonNull();
122 const label len = this->size();
124 if (order.
size() != len)
127 <<
"Size of map (" << order.
size()
128 <<
") not equal to list size (" << len
129 <<
") for type " << error::demangle<T>() <<
nl 133 Detail::PtrListDetail<T> newList(len);
134 Detail::PtrListDetail<T> guard(len);
136 for (label i = 0; i < len; ++i)
138 const label oldIdx = order[i];
140 if (oldIdx < 0 || oldIdx >= len)
143 <<
"Illegal index " << oldIdx <<
nl 144 <<
"Valid indices are [0," << len <<
") for type " 145 << error::demangle<T>() <<
nl 152 <<
"order map is not unique; element " << oldIdx
153 <<
" already used for type " 154 << error::demangle<T>() <<
nl 158 guard[oldIdx] = ptrs_[oldIdx];
159 newList[i] = ptrs_[oldIdx];
165 newList.checkNonNull();
178 return ptrs_.printAddresses(os);
189 return ptrs_.
write(os, trimNull);
194 Foam::Ostream& Foam::operator<<(Ostream& os, const UPtrList<T>& list)
196 return list.writeList(os,
false);
210 [](
const T*
const a,
const T*
const b) ->
bool 212 return (a &&
b) ? (*a < *
b) : !
b;
218 template<
class T,
class Compare>
219 void Foam::sort(UPtrList<T>& list,
const Compare& comp)
225 typename UPtrList<T>::template value_compare<Compare>(comp)
Ostream & printAddresses(Ostream &os) const
Print pointer addresses to Ostream (debugging only)
void size(const label n)
Older name for setAddressableSize.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr char nl
The newline '\n' character (0x0a)
void reorder(const labelUList &oldToNew, const bool check=false)
Reorder elements. Reordering must be unique (ie, shuffle).
constexpr UPtrList() noexcept=default
Default construct.
UList< label > labelUList
A UList of labels.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
void sort(UList< T > &list)
Sort the list.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
errorManip< error > abort(error &err)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Ostream & writeList(Ostream &os, const bool trimNull=false) const
Write UPtrList to Ostream, optionally ignoring null entries.
static void check(const int retVal, const char *what)
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
label squeezeNull()
Squeeze out nullptr entries in the list of pointers after which any null pointers will be at the end ...
void sortOrder(const labelUList &order, const bool check=false)
Reorder elements according to new order mapping (newToOld). Reordering must be unique (ie...