35 const UPtrList<T>& list
55template<
class T,
class ListComparePredicate>
60 const ListComparePredicate& comp
68 for (label& item : order)
74 std::stable_sort(order.
begin(), order.
end(), comp);
91template<
class ReturnType,
class T,
class AccessOp>
94 const UPtrList<T>& list,
98 const label len = list.size();
100 List<ReturnType> output(len);
103 for (label i = 0; i < len; ++i)
105 const T* ptr = list.get(i);
109 output[count++] = aop(*ptr);
113 output.resize(count);
119template<
class T,
class UnaryMatchPredicate>
122 const UPtrList<T>& list,
123 const UnaryMatchPredicate& matcher
128 const label len = list.
size();
130 List<word> output(len);
133 for (label i = 0; i < len; ++i)
135 const T* ptr = list.get(i);
139 if (matcher(ptr->name()))
141 output[
count++] = (ptr->name());
146 output.resize(count);
155 const UPtrList<T>& list
158 return PtrListOps::names(list, predicates::always());
162template<
class T,
class UnaryMatchPredicate>
165 const UPtrList<T>& list,
166 const UnaryMatchPredicate& matcher
169 const label len = list.size();
171 for (label i = 0; i < len; ++i)
173 const T* ptr = list.get(i);
175 if (
bool(ptr) && matcher(ptr->name()))
185template<
class T,
class UnaryMatchPredicate>
188 const UPtrList<T>& list,
189 const UnaryMatchPredicate& matcher
192 const label len = list.
size();
197 for (label i = 0; i < len; ++i)
199 const T* ptr = list.get(i);
201 if (
bool(ptr) && matcher(ptr->name()))
207 output.resize(count);
Functions to operate on Pointer Lists.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
iterator end() noexcept
Return an iterator to end traversing the UList.
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...
void sortOrder(const labelUList &order, const bool check=false)
label size() const noexcept
The number of elements in the list.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
labelList findMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Extract list indices for all items with 'name()' that matches.
label firstMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Find first list item with 'name()' that matches, -1 on failure.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
void shuffle(UList< T > &list)
Randomise the list order.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.