47 const label len = this->size();
50 for (label i=0; i < len; ++i)
71 label newLen = this->size();
73 for (label i = newLen-1; i >= 0 && !ptrs_[i]; --i)
81 ptrs_.setAddressableSize(newLen);
88 const label len = this->size();
90 if (oldToNew.
size() != len)
93 <<
"Size of map (" << oldToNew.
size()
94 <<
") not equal to list size (" << len
95 <<
") for type " <<
typeid(
T).
name() <<
nl 99 Detail::PtrListDetail<T> newList(len);
101 for (label i=0; i<len; ++i)
103 const label newIdx = oldToNew[i];
105 if (newIdx < 0 || newIdx >= len)
108 <<
"Illegal index " << newIdx <<
nl 109 <<
"Valid indices are [0," << len <<
") for type " 117 <<
"reorder map is not unique; element " << newIdx
118 <<
" already used for type " <<
typeid(
T).
name()
121 newList[newIdx] = ptrs_[i];
127 newList.checkNonNull();
130 ptrs_.transfer(newList);
137 const label len = this->size();
139 if (order.size() != len)
142 <<
"Size of map (" << order.size()
143 <<
") not equal to list size (" << len
144 <<
") for type " <<
typeid(
T).
name() <<
nl 148 Detail::PtrListDetail<T> newList(len);
149 Detail::PtrListDetail<T> guard(len);
151 for (label i=0; i<len; ++i)
153 const label oldIdx = order[i];
155 if (oldIdx < 0 || oldIdx >= len)
158 <<
"Illegal index " << oldIdx <<
nl 159 <<
"Valid indices are [0," << len <<
") for type " 167 <<
"order map is not unique; element " << oldIdx
168 <<
" already used for type " <<
typeid(
T).
name()
172 guard[oldIdx] = ptrs_[oldIdx];
173 newList[i] = ptrs_[oldIdx];
179 newList.checkNonNull();
182 ptrs_.transfer(newList);
189 Foam::Ostream& Foam::operator<<(Ostream& os, const UPtrList<T>& list)
205 [](
const T*
const a,
const T*
const b) ->
bool 207 return (a &&
b) ? (*a < *
b) : !
b;
213 template<
class T,
class Compare>
214 void Foam::sort(UPtrList<T>& list,
const Compare& comp)
220 typename UPtrList<T>::template value_compare<Compare>(comp)
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.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
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...
OBJstream os(runTime.globalPath()/outputName)
static void check(const int retVal, const char *what)
void trimTrailingNull()
Reduce addressable list size to ignore any trailing null pointers.
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...