30 template<
class ListType>
38 ListType newLst(lst.size());
41 newLst.setSize(lst.size());
47 newLst[elemI] = oldToNew[lst[elemI]];
55 template<
class ListType>
66 lst[elemI] = oldToNew[lst[elemI]];
72 template<
class ListType>
80 ListType newLst(lst.size());
83 newLst.setSize(lst.size());
87 if (oldToNew[elemI] >= 0)
89 newLst[oldToNew[elemI]] = lst[elemI];
93 newLst[elemI] = lst[elemI];
100 template<
class ListType>
108 ListType newLst(lst.size());
111 newLst.setSize(lst.size());
115 if (oldToNew[elemI] >= 0)
117 newLst[oldToNew[elemI]] = lst[elemI];
121 newLst[elemI] = lst[elemI];
125 lst.transfer(newLst);
129 template<
class Container>
138 typename Container::iterator iter = lst.begin();
145 *iter = oldToNew[*iter];
151 template<
class Container>
158 Container newLst(lst.size());
162 typename Container::iterator iter = lst.begin();
169 newLst.insert(oldToNew[iter.key()], iter());
173 lst.transfer(newLst);
188 template<
class T,
class Cmp>
206 order[elemI] = elemI;
223 template<
class T,
class Cmp>
240 for (
label i = 0; i < order.
size() - 1; ++i)
242 if (lst[order[i]] == lst[order[i+1]])
244 order[n++] = order[i];
262 template<
class T,
class Cmp>
272 if (order.
size() > 1)
275 for (
label i = 0; i < order.
size() - 1; ++i)
277 if (lst[order[i]] != lst[order[i+1]])
279 order[n++] = order[i];
282 order[n++] = order[order.
size()-1];
288 template<
class T,
class ListType>
297 if (select.
size() < lst.size())
300 <<
"select is of size " << select.
size()
301 <<
"; but it must index a list of size " << lst.size()
305 ListType newLst(lst.size());
308 newLst.setSize(lst.size());
313 if (select[elemI] == value)
315 newLst[nElem++] = lst[elemI];
318 newLst.setSize(nElem);
324 template<
class T,
class ListType>
333 if (select.
size() < lst.size())
336 <<
"select is of size " << select.
size()
337 <<
"; but it must index a list of size " << lst.size()
344 if (select[elemI] == value)
348 lst[nElem] = lst[elemI];
358 template<
class BoolListType,
class ListType>
361 const BoolListType& select,
368 ListType newLst(lst.size());
371 newLst.setSize(lst.size());
378 newLst[nElem++] = lst[elemI];
381 newLst.setSize(nElem);
387 template<
class BoolListType,
class ListType>
390 const BoolListType& select,
404 lst[nElem] = lst[elemI];
414 template<
class InList,
class OutList>
425 forAll(pointEdges, pointi)
427 const InList& pEdges = pointEdges[pointi];
431 nPointsPerEdge[pEdges[j]]++;
438 forAll(nPointsPerEdge, edgeI)
440 edges[edgeI].
setSize(nPointsPerEdge[edgeI]);
445 forAll(pointEdges, pointi)
447 const InList& pEdges = pointEdges[pointi];
451 label edgeI = pEdges[j];
453 edges[edgeI][nPointsPerEdge[edgeI]++] = pointi;
459 template<
class ListType>
463 typename ListType::const_reference t,
469 for (
label i = start; i < l.size(); i++)
482 template<
class ListType>
486 typename ListType::const_reference t,
493 for (
label i = start; i < l.size(); i++)
505 for (
label i = start; i < l.size(); i++)
517 template<
class ListType>
522 typename ListType::const_reference t
532 template<
class ListType>
536 const typename ListType::const_reference initValue,
538 typename ListType::const_reference setValue
541 ListType l(sz, initValue);
547 template<
class ListType>
550 if (start >= l.size())
557 for (
label i = start+1; i < l.size(); i++)
569 template<
class ListType>
572 if (start >= l.size())
579 for (
label i = start+1; i < l.size(); i++)
591 template<
class ListType>
595 typename ListType::const_reference t,
599 if (start >= l.size())
605 label high = l.size() - 1;
609 label mid = (low + high)/2;
629 template<
class ListType,
class BinaryOp>
633 typename ListType::const_reference t,
638 if (start >= l.size())
644 label high = l.size() - 1;
646 while ((high - low) > 1)
648 label mid = (low + high)/2;
678 template<
class ListType>
682 typename ListType::const_reference t,
690 template<
class Container,
class T,
int mRows>
697 lst[rowI] = Container(elems[rowI]);
703 template<
class Container,
class T,
int mRows,
int nColumns>
708 Container cols(nColumns);
713 cols[colI] = elems[rowI][colI];
743 template<
class ListType>
746 const label listSize = list.size();
747 const label lastIndex = listSize - 1;
749 ListType tmpList(listSize);
753 tmpList[elemI] = list[lastIndex - elemI];
760 template<
class ListType>
763 const label listSize = list.size();
764 const label lastIndex = listSize - 1;
765 const label nIterations = listSize >> 1;
768 while (elemI < nIterations)
770 Swap(list[elemI], list[lastIndex - elemI]);
777 template<
class ListType>
780 const label listSize = list.size();
782 ListType tmpList(listSize);
786 label index = (elemI -
n) % listSize;
793 tmpList[elemI] = list[index];
800 template<
template<
typename>
class ListType,
class DataType>
803 const label listSize = list.size();
805 n = (listSize -
n) % listSize;
void inplaceSubset(const UList< T > &select, const T &value, ListType &)
Inplace extract elements of List when select is a certain value.
void inplaceMapKey(const labelUList &oldToNew, Container &)
Recreate with mapped keys. Do not map elements with negative key.
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
void duplicateOrder(const UList< T > &, labelList &order)
Generate (sorted) indices corresponding to duplicate list values.
void inplaceReorder(const labelUList &oldToNew, ListType &)
Inplace reorder the elements of a list.
label findSortedIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element in sorted list and return index,.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
ListType rotateList(const ListType &list, const label n)
Rotate a list by n places. If n is positive rotate clockwise/right/down.
void size(const label)
Override size to be inconsistent with allocated storage.
void uniqueOrder(const UList< T > &, labelList &order)
Generate (sorted) indices corresponding to unique list values.
List< Container > initList(const T[mRows])
To construct a List from a C array. Has extra Container type.
void setValues(ListType &, const labelUList &indices, typename ListType::const_reference)
Opposite of findIndices: set values at indices to given value.
label findMin(const ListType &, const label start=0)
Find index of min element (and less than given element).
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
ListType createWithValues(const label sz, typename ListType::const_reference initValue, const labelUList &indices, typename ListType::const_reference setValue)
Opposite of findIndices: set values at indices to given value.
Various functions to operate on Lists.
void inplaceReverseList(ListType &list)
Inplace reversal of a list using Swap.
A List obtained as a section of another List.
Less function class that can be used for sorting.
void operator()(List< T > &x, const List< T > &y) const
void clear()
Clear the list, i.e. set size to zero.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
ListType reverseList(const ListType &list)
Reverse a list. First element becomes last element etc.
label findMax(const ListType &, const label start=0)
Find index of max element (and larger than given element).
ListType reorder(const labelUList &oldToNew, const ListType &)
Reorder the elements (indices, not values) of a list.
List< Container > initListList(const T[mRows][nColumns])
To construct a (square) ListList from a C array. Has extra Container type.
void inplaceMapValue(const labelUList &oldToNew, Container &)
Map values. Do not map negative values.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
void setSize(const label)
Reset size of List.
void inplaceRotateList(ListType< DataType > &list, label n)
Inplace reversal of a list using the Reversal Block Swapping algorithm.
void invertManyToMany(const label len, const UList< InList > &, List< OutList > &)
Invert many-to-many.
ListType subset(const UList< T > &select, const T &value, const ListType &)
Extract elements of List when select is a certain value.
label findLower(const ListType &, typename ListType::const_reference, const label stary, const BinaryOp &bop)
Find last element < given value in sorted list and return index,.
label size() const
Return the number of elements in the UList.
void stableSort(UList< T > &)