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,
724 return findLower(l, t, start, lessOp<typename ListType::value_type>());
728 template<
class Container,
class T,
int mRows>
731 List<Container> lst(mRows);
735 lst[rowI] = Container(elems[rowI]);
741 template<
class Container,
class T,
int mRows,
int nColumns>
744 List<Container> lst(mRows);
746 Container cols(nColumns);
751 cols[colI] = elems[rowI][colI];
759 template<
class ListType>
762 const label listSize = list.size();
763 const label lastIndex = listSize - 1;
765 ListType tmpList(listSize);
769 tmpList[elemI] = list[lastIndex - elemI];
776 template<
class ListType>
779 const label listSize = list.size();
780 const label lastIndex = listSize - 1;
781 const label nIterations = listSize >> 1;
784 while (elemI < nIterations)
786 Swap(list[elemI], list[lastIndex - elemI]);
793 template<
class ListType>
796 const label listSize = list.size();
798 ListType tmpList(listSize);
802 label index = (elemI -
n) % listSize;
809 tmpList[elemI] = list[index];
816 template<
template<
typename>
class ListType,
class DataType>
819 const label listSize = list.size();
821 n = (listSize -
n) % listSize;
838 template<
class Type,
template<
class>
class BinaryOp>
848 c[i] = BinaryOp<Type>()(a[i],
b[i]);
854 template<
class Type,
template<
class>
class BinaryEqOp>
863 BinaryEqOp<Type>()(a[i],
b[i]);
876 x.setSize(sz +
y.size());
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
void size(const label)
Override size to be inconsistent with allocated storage.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
A List obtained as a section of another List.
Less function class that can be used for sorting.
label size() const
Return the number of elements in the UList.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const dimensionedScalar c
Speed of light in a vacuum.
List< Container > initList(const T[mRows])
To construct a List from a C array. Has extra Container type.
void inplaceMapValue(const labelUList &oldToNew, Container &)
Map values. Do not map negative values.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
label findMax(const ListType &, const label start=0)
Find index of max element (and larger than given element).
ListType reverseList(const ListType &list)
Reverse a list. First element becomes last element etc.
void inplaceReverseList(ListType &list)
Inplace reversal of a list using Swap.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
void duplicateOrder(const UList< T > &, labelList &order)
Generate (sorted) indices corresponding to duplicate list values.
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 stary, const BinaryOp &bop)
Find last element < given value in sorted list and return index,.
void inplaceSubset(const UList< T > &select, const T &value, ListType &)
Inplace extract elements of List when select is a certain value.
errorManip< error > abort(error &err)
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
ListType rotateList(const ListType &list, const label n)
Rotate a list by n places. If n is positive rotate clockwise/right/down.
void inplaceRotateList(ListType< DataType > &list, label n)
Inplace reversal of a list using the Reversal Block Swapping algorithm.
label findSortedIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element in sorted list and return index,.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
label findMin(const ListType &, const label start=0)
Find index of min element (and less than given element).
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
List< Container > initListList(const T[mRows][nColumns])
To construct a (square) ListList from a C array. Has extra Container type.
void stableSort(UList< T > &)
ListType reorder(const labelUList &oldToNew, const ListType &)
Reorder the elements (indices, not values) of a list.
void uniqueOrder(const UList< T > &, labelList &order)
Generate (sorted) indices corresponding to unique list values.
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
void setValues(ListType &, const labelUList &indices, typename ListType::const_reference)
Opposite of findIndices: set values at indices to given value.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
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.
ListType subset(const UList< T > &select, const T &value, const ListType &)
Extract elements of List when select is a certain value.
void invertManyToMany(const label len, const UList< InList > &, List< OutList > &)
Invert many-to-many.
void inplaceReorder(const labelUList &oldToNew, ListType &)
Inplace reorder the elements of a list.
void operator()(List< T > &x, const List< T > &y) const
Operator to apply a binary-equals operation to a pair of lists.
Operator to apply a binary operation to a pair of lists.