30 template<
class ListType>
41 template<
class ListType>
49 newLst.setSize(lst.size());
53 renumber(oldToNew, lst[elemI], newLst[elemI]);
67 newLst = oldToNew[lst];
72 template<
class ListType>
91 template<
class ListType>
99 ListType newLst(lst.size());
102 newLst.setSize(lst.size());
106 if (oldToNew[elemI] >= 0)
108 newLst[oldToNew[elemI]] = lst[elemI];
112 newLst[elemI] = lst[elemI];
119 template<
class ListType>
127 ListType newLst(lst.size());
130 newLst.setSize(lst.size());
134 if (oldToNew[elemI] >= 0)
136 newLst[oldToNew[elemI]] = lst[elemI];
140 newLst[elemI] = lst[elemI];
144 lst.transfer(newLst);
148 template<
class Container>
157 typename Container::iterator iter = lst.begin();
164 *iter = oldToNew[*iter];
170 template<
class Container>
177 Container newLst(lst.size());
181 typename Container::iterator iter = lst.begin();
188 newLst.insert(oldToNew[iter.key()], iter());
192 lst.transfer(newLst);
207 template<
class T,
class Cmp>
225 order[elemI] = elemI;
242 template<
class T,
class Cmp>
259 for (
label i = 0; i < order.
size() - 1; ++i)
261 if (lst[order[i]] == lst[order[i+1]])
263 order[n++] = order[i];
281 template<
class T,
class Cmp>
291 if (order.
size() > 1)
294 for (
label i = 0; i < order.
size() - 1; ++i)
296 if (lst[order[i]] != lst[order[i+1]])
298 order[n++] = order[i];
301 order[n++] = order[order.
size()-1];
307 template<
class T,
class ListType>
316 if (select.
size() < lst.size())
319 <<
"select is of size " << select.
size()
320 <<
"; but it must index a list of size " << lst.size()
324 ListType newLst(lst.size());
327 newLst.setSize(lst.size());
332 if (select[elemI] == value)
334 newLst[nElem++] = lst[elemI];
337 newLst.setSize(nElem);
343 template<
class T,
class ListType>
352 if (select.
size() < lst.size())
355 <<
"select is of size " << select.
size()
356 <<
"; but it must index a list of size " << lst.size()
363 if (select[elemI] == value)
367 lst[nElem] = lst[elemI];
377 template<
class BoolListType,
class ListType>
380 const BoolListType& select,
387 ListType newLst(lst.size());
390 newLst.setSize(lst.size());
397 newLst[nElem++] = lst[elemI];
400 newLst.setSize(nElem);
406 template<
class BoolListType,
class ListType>
409 const BoolListType& select,
423 lst[nElem] = lst[elemI];
433 template<
class InList,
class OutList>
444 forAll(pointEdges, pointi)
446 const InList& pEdges = pointEdges[pointi];
450 nPointsPerEdge[pEdges[j]]++;
457 forAll(nPointsPerEdge, edgeI)
459 edges[edgeI].
setSize(nPointsPerEdge[edgeI]);
464 forAll(pointEdges, pointi)
466 const InList& pEdges = pointEdges[pointi];
470 label edgeI = pEdges[j];
472 edges[edgeI][nPointsPerEdge[edgeI]++] = pointi;
478 template<
class ListType>
482 typename ListType::const_reference x
497 template<
class ListType>
501 typename ListType::const_reference t,
507 for (
label i = start; i < l.size(); i++)
520 template<
class ListType>
524 typename ListType::const_reference t,
531 for (
label i = start; i < l.size(); i++)
543 for (
label i = start; i < l.size(); i++)
555 template<
class ListType>
560 typename ListType::const_reference t
570 template<
class ListType>
574 const typename ListType::const_reference initValue,
576 typename ListType::const_reference setValue
579 ListType l(sz, initValue);
585 template<
class ListType>
588 if (start >= l.size())
595 for (
label i = start+1; i < l.size(); i++)
607 template<
class ListType>
610 if (start >= l.size())
617 for (
label i = start+1; i < l.size(); i++)
629 template<
class ListType>
633 typename ListType::const_reference t,
637 if (start >= l.size())
643 label high = l.size() - 1;
647 label mid = (low + high)/2;
667 template<
class ListType,
class BinaryOp>
671 typename ListType::const_reference t,
676 if (start >= l.size())
682 label high = l.size() - 1;
684 while ((high - low) > 1)
686 label mid = (low + high)/2;
716 template<
class ListType>
720 typename ListType::const_reference t,
728 template<
class Container,
class T,
int mRows>
735 lst[rowI] = Container(elems[rowI]);
741 template<
class Container,
class T,
int mRows,
int nColumns>
746 Container cols(nColumns);
751 cols[colI] = elems[rowI][colI];
781 template<
class ListType>
784 const label listSize = list.size();
785 const label lastIndex = listSize - 1;
787 ListType tmpList(listSize);
791 tmpList[elemI] = list[lastIndex - elemI];
798 template<
class ListType>
801 const label listSize = list.size();
802 const label lastIndex = listSize - 1;
803 const label nIterations = listSize >> 1;
806 while (elemI < nIterations)
808 Swap(list[elemI], list[lastIndex - elemI]);
815 template<
class ListType>
818 const label listSize = list.size();
820 ListType tmpList(listSize);
824 label index = (elemI -
n) % listSize;
831 tmpList[elemI] = list[index];
838 template<
template<
typename>
class ListType,
class DataType>
841 const label listSize = list.size();
843 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.
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
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 > &)