45 #ifndef Foam_ListOps_H 46 #define Foam_ListOps_H 63 template<
class T>
class CompactListList;
68 template<
class IntListType>
73 template<
class IntListType>
78 template<
class IntListType>
87 template<
class ListType>
91 const ListType&
input,
92 const bool prune =
false 100 template<
class ListType>
105 const bool prune =
false 112 template<
unsigned W
idth>
116 const PackedList<Width>&
input,
117 const bool prune =
false 123 template<
unsigned W
idth>
127 PackedList<Width>&
input,
128 const bool prune =
false 138 const bool prune =
false 147 const bool prune =
false 153 template<
class Container>
158 template<
class Container>
187 template<
class Container>
201 template<
class T,
class ListComparePredicate>
204 const UList<T>&
input,
206 const ListComparePredicate& comp
220 template<
class T,
class ListComparePredicate>
223 const UList<T>&
input,
225 const ListComparePredicate& comp
235 template<
class ListType>
240 template<
class ListType,
class ListComparePredicate>
244 const ListComparePredicate& comp
263 template<
class BoolListType,
class T>
266 const BoolListType&
select,
267 const UList<T>&
input,
283 const UList<T>&
input,
295 template<
class BoolListType,
class ListType>
298 const BoolListType&
select,
311 template<
class ListType>
327 template<
class T,
class UnaryPredicate>
330 const UList<T>&
input,
331 const UnaryPredicate& pred,
342 template<
class ListType,
class UnaryPredicate>
346 const UnaryPredicate& pred,
395 template<
class InputIntListType,
class OutputIntListType>
399 const UList<InputIntListType>&
input,
400 List<OutputIntListType>&
output 403 template<
class InputIntListType,
class OutputIntListType>
407 const UList<InputIntListType>&
input 410 List<OutputIntListType>
output;
411 invertManyToMany<InputIntListType,OutputIntListType>(len,
input,
output);
419 template<
class ListType>
423 const ListType&
input,
424 typename ListType::const_reference val,
428 return input.find(val, start);
433 template<
class ListType>
436 const ListType&
input,
437 typename ListType::const_reference val,
451 template<
class ListType>
463 template<
class ListType>
477 template<
class ListType>
495 template<
class ListType>
498 const ListType&
input,
499 typename ListType::const_reference val,
522 template<
class ListType,
class T,
class ComparePredicate>
525 const ListType&
input,
528 const ComparePredicate& comp
546 template<
class ListType,
class T>
549 const ListType&
input,
556 template<
class ListType>
561 template<
class ListType>
568 template<
class ListType>
569 ListType
rotateList(
const ListType& list,
const label
n);
573 template<
template<
typename>
class ListType,
class DataType>
608 template<
class ListType>
613 less(
const ListType& list)
618 bool operator()(
const label a,
const label
b)
const 626 template<
class ListType>
636 bool operator()(
const label a,
const label
b)
const 656 template<
class ListType,
class UnaryPredicate>
659 const ListType&
input,
660 const UnaryPredicate& pred,
670 template<
class ListType,
class UnaryPredicate>
673 const ListType&
input,
674 const UnaryPredicate& pred,
680 template<
class ListType,
class UnaryPredicate>
683 const ListType&
input,
684 const UnaryPredicate& pred,
696 template<
class ListType,
class UnaryPredicate>
699 const ListType&
input,
700 const UnaryPredicate& pred,
706 template<
class ListType,
class UnaryPredicate>
709 const ListType&
input,
710 const UnaryPredicate& pred,
719 template<
class ListType,
class UnaryPredicate>
722 const ListType&
input,
723 const UnaryPredicate& pred,
815 template<
class T,
class T2,
class UnaryOperation>
819 const UnaryOperation& op
830 template<
class T,
class InputIterator,
class UnaryOperation>
835 const UnaryOperation& op
List< T > uniqueSort(const UList< T > &input)
Return sorted list with removal of duplicates.
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as ListOps::find_if.
label findMax(const ListType &input, label start=0)
Linear search for the index of the max element, similar to std::max_element but for lists and returns...
void operator()(labelList &x, const labelList &y) const
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
Binary search to find the index of the last element in a sorted list that is less than value...
label count_if(const ListType &input, const UnaryPredicate &pred, const label start=0)
Count the number of matching entries.
labelPair findMinMax(const ListType &input, label start=0)
Linear search for the index of the min/max element, similar to std::minmax_element but for lists and ...
labelList findIndices(const ListType &input, const UnaryPredicate &pred, label start=0)
Linear search to find all occurences of given element.
bool operator()(const label a, const label b) const
bool found(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as found_if.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
ListType rotateList(const ListType &list, const label n)
Rotate a list by n places.
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values within a list.
labelList duplicateOrder(const UList< T > &input)
Return (sorted) indices corresponding to duplicate list values.
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
label findSortedIndex(const ListType &input, typename ListType::const_reference val, const label start=0)
Binary search to find the index of the last element in a sorted list that is less than value...
Various functors for unary and binary operations. Can be used for parallel combine-reduce operations ...
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
label inplaceMapValue(const labelUList &oldToNew, Container &input)
Map values. Ignore negative values.
greater(const ListType &list)
void inplaceSubset(const BoolListType &select, ListType &input, const bool invert=false)
Inplace extract elements of the input list when select is true.
List< labelList > labelListList
List of labelList.
static bool less(const vector &x, const vector &y)
To compare normals.
UList< label > labelUList
A UList of labels.
void inplaceSubsetList(ListType &input, const UnaryPredicate &pred, const bool invert=false)
Inplace subset of the list when predicate is true.
void operator()(List< T > &x, const List< T > &y) const
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
bool found_if(const ListType &input, const UnaryPredicate &pred, const label start=0)
True if there is a value in the list that satisfies the predicate.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
label findMin(const ListType &input, label start=0)
Linear search for the index of the min element, similar to std::min_element but for lists and returns...
CompactListList< label > invertOneToManyCompact(const label len, const labelUList &map)
Invert one-to-many compact map. Unmapped elements will be size 0.
ListType reverseList(const ListType &input)
Reverse a list. First element becomes last element etc.
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
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...
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
List< T > subsetList(const UList< T > &input, const UnaryPredicate &pred, const bool invert=false)
Copy a subset of the input list when predicate is true.
void identity(labelUList &map, label start=0)
Fill an identity map with (map[i] == i)
static Istream & input(Istream &is, IntRange< T > &range)
void operator()(List< T > &x, const List< T > &y) const
void inplaceUniqueSort(ListType &input)
Inplace sorting and removal of duplicates.
#define FOAM_DEPRECATED_STRICT(since, replacement)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
List< T > create(const UList< T2 > &input, const UnaryOperation &op)
Create a List from a List of a dissimilar type, using the entire list.
Pair< label > labelPair
A pair of labels.
void inplaceMapKey(const labelUList &oldToNew, Container &input)
Rewrite with mapped keys. Ignore elements with negative key.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
labelList uniqueOrder(const UList< T > &input)
Return (sorted) indices corresponding to unique list values.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values within a list.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void inplaceRotateList(ListType< DataType > &list, label n)
Inplace reversal of a list using the Reversal Block Swapping algorithm.
label find_if(const ListType &input, const UnaryPredicate &pred, const label start=0)
Find index of the first occurrence that satisfies the predicate.
static Ostream & output(Ostream &os, const IntRange< T > &range)
bool operator()(const label a, const label b) const
List< T > createWithValue(const label len, const labelUList &locations, const T &val, const T &deflt=T())
Create a List filled with default values and various locations with another specified value...
label findIndex(const ListType &input, typename ListType::const_reference val, const label start=0)
Deprecated(2017-10) search for first occurrence of the given element.
List< label > labelList
A List of labels.
void setValue(UList< T > &list, const labelUList &locations, const T &val)
Set various locations of the list with a specified value.
void invertManyToMany(const label len, const UList< InputIntListType > &input, List< OutputIntListType > &output)
Invert many-to-many.
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
Reorder the elements of a list.
void inplaceReverseList(ListType &input)
Inplace reversal of a list using Swap.
Map< label > invertToMap(const labelUList &values)
Create inverse mapping, which is a lookup table into the given list.
less(const ListType &list)