35 const UPtrList<T>& list
47 const UPtrList<T>& list,
55template<
class T,
class ListComparePredicate>
58 const UPtrList<T>& list,
60 const ListComparePredicate& comp
68 std::stable_sort(order.begin(), order.end(), comp);
78 labelList order(identity(list.size()));
80 list.sortOrder(order,
false);
85template<
class ReturnType,
class T,
class AccessOp>
88 const UPtrList<T>& list,
92 const label len = list.
size();
94 List<ReturnType> output(len);
97 for (label i = 0; i < len; ++i)
99 const T* ptr = list.get(i);
103 output[
count++] = aop(*ptr);
107 output.resize(count);
113template<
class T,
class UnaryMatchPredicate>
116 const UPtrList<T>& list,
117 const UnaryMatchPredicate& matcher
122 const label len = list.
size();
124 List<word> output(len);
127 for (label i = 0; i < len; ++i)
129 const T* ptr = list.get(i);
131 if (
bool(ptr) && matcher(ptr->name()))
133 output[
count++] = (ptr->name());
137 output.resize(count);
146 const UPtrList<T>& list
149 return PtrListOps::names(list, predicates::always());
153template<
class T,
class UnaryMatchPredicate>
156 const UPtrList<T>& list,
157 const UnaryMatchPredicate& matcher
160 const label len = list.size();
162 for (label i = 0; i < len; ++i)
164 const T* ptr = list.get(i);
166 if (
bool(ptr) && matcher(ptr->name()))
176template<
class T,
class UnaryMatchPredicate>
179 const UPtrList<T>& list,
180 const UnaryMatchPredicate& matcher
183 const label len = list.
size();
188 for (label i = 0; i < len; ++i)
190 const T* ptr = list.get(i);
192 if (
bool(ptr) && matcher(ptr->name()))
198 output.resize(count);
Functions to operate on Pointer Lists.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
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)
Reorder elements according to new order mapping (newToOld). Reordering must be unique (ie,...
label size() const noexcept
The number of entries 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)
List of values generated by applying the access operation to each list item.
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)
List of names generated by calling name() for each list item and filtered for matches.
void shuffle(UList< T > &list)
Randomise the list order.
List< label > labelList
A List of labels.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
A UPtrList compare binary predicate for normal sort order. Null entries (if any) sort to the end.