Go to the documentation of this file.
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];
416 template<
class InList,
class OutList>
427 forAll(pointEdges, pointI)
429 const InList& pEdges = pointEdges[pointI];
433 nPointsPerEdge[pEdges[j]]++;
440 forAll(nPointsPerEdge, edgeI)
442 edges[edgeI].
setSize(nPointsPerEdge[edgeI]);
447 forAll(pointEdges, pointI)
449 const InList& pEdges = pointEdges[pointI];
453 label edgeI = pEdges[j];
455 edges[edgeI][nPointsPerEdge[edgeI]++] = pointI;
461 template<
class ListType>
465 typename ListType::const_reference t,
471 for (
label i = start; i < l.size(); i++)
484 template<
class ListType>
488 typename ListType::const_reference t,
495 for (
label i = start; i < l.size(); i++)
507 for (
label i = start; i < l.size(); i++)
519 template<
class ListType>
524 typename ListType::const_reference t
534 template<
class ListType>
538 const typename ListType::const_reference initValue,
540 typename ListType::const_reference setValue
543 ListType l(sz, initValue);
549 template<
class ListType>
552 if (start >= l.size())
559 for (
label i = start+1; i < l.size(); i++)
571 template<
class ListType>
574 if (start >= l.size())
581 for (
label i = start+1; i < l.size(); i++)
593 template<
class ListType>
597 typename ListType::const_reference t,
601 if (start >= l.size())
607 label high = l.size() - 1;
611 label mid = (low + high)/2;
631 template<
class ListType,
class BinaryOp>
635 typename ListType::const_reference t,
640 if (start >= l.size())
646 label high = l.size() - 1;
648 while ((high - low) > 1)
650 label mid = (low + high)/2;
680 template<
class ListType>
684 typename ListType::const_reference t,
688 return findLower(l, t, start, lessOp<typename ListType::value_type>());
692 template<
class Container,
class T,
int nRows>
699 lst[rowI] = Container(elems[rowI]);
705 template<
class Container,
class T,
int nRows,
int nColumns>
710 Container cols(nColumns);
715 cols[colI] = elems[rowI][colI];
731 x.setSize(sz +
y.size());
768 template<
class ListType>
771 const label listSize = list.size();
772 const label lastIndex = listSize - 1;
774 ListType tmpList(listSize);
778 tmpList[elemI] = list[lastIndex - elemI];
785 template<
class ListType>
788 const label listSize = list.size();
789 const label lastIndex = listSize - 1;
790 const label nIterations = listSize >> 1;
793 while (elemI < nIterations)
795 Swap(list[elemI], list[lastIndex - elemI]);
802 template<
class ListType>
805 const label listSize = list.size();
807 ListType tmpList(listSize);
811 label index = (elemI -
n) % listSize;
818 tmpList[elemI] = list[index];
825 template<
template<
typename>
class ListType,
class DataType>
828 const label listSize = list.size();
830 n = (listSize -
n) % listSize;
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.
label findMax(const ListType &, const label start=0)
Find index of max element (and larger than given element).
void inplaceMapValue(const labelUList &oldToNew, Container &)
Map values. Do not map negative values.
ListType reverseList(const ListType &list)
Reverse a list. First element becomes last element etc.
List< label > labelList
A List of labels.
ListType reorder(const labelUList &oldToNew, const ListType &)
Reorder the elements (indices, not values) of a list.
#define forAll(list, i)
Loop across all elements in list.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
A List obtained as a section of another 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 renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
void setValues(ListType &, const labelUList &indices, typename ListType::const_reference)
Opposite of findIndices: set values at indices to given value.
label findSortedIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element in sorted list and return index,.
label findMin(const ListType &, const label start=0)
Find index of min element (and less than given element).
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
void stableSort(UList< T > &)
void inplaceReorder(const labelUList &oldToNew, ListType &)
Inplace reorder the elements of a 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 duplicateOrder(const UList< T > &, labelList &order)
Generate (sorted) indices corresponding to duplicate list values.
void operator()(List< T > &x, const List< T > &y) const
void inplaceMapKey(const labelUList &oldToNew, Container &)
Recreate with mapped keys. Do not map elements with negative key.
label findLower(const ListType &, typename ListType::const_reference, const label start, const BinaryOp &bop)
Find last element < given value in sorted list and return index,.
List< Container > initListList(const T[nRows][nColumns])
To construct a (square) ListList from a C array. Has extra Container type.
ListType rotateList(const ListType &list, const label n)
Rotate a list by n places. If n is positive rotate clockwise/right/down.
errorManip< error > abort(error &err)
ListType subset(const UList< T > &select, const T &value, const ListType &)
Extract elements of List when select is a certain value.
void setSize(const label)
Reset size of List.
void uniqueOrder(const UList< T > &, labelList &order)
Generate (sorted) indices corresponding to unique list values.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< Container > initList(const T[nRows])
To construct a List from a C array. Has extra Container type.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void inplaceReverseList(ListType &list)
Inplace reversal of a list using Swap.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void clear()
Clear the list, i.e. set size to zero.
void inplaceSubset(const UList< T > &select, const T &value, ListType &)
Inplace extract elements of List when select is a certain value.
Various functions to operate on Lists.
void size(const label)
Override size to be inconsistent with allocated storage.
label size() const
Return the number of elements in the UList.
void operator()(List< T > &x, const List< T > &y) const
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurences of given element. Linear search.