Go to the documentation of this file.
35 template<
class IntListType>
39 const IntListType&
input
42 const label len =
input.size();
47 for (label i=0; i < len; ++i)
59 template<
class IntListType>
66 const label len =
input.size();
68 for (label i=0; i < len; ++i)
78 template<
class ListType>
82 const ListType&
input,
86 const label len =
input.size();
92 for (label i=0; i < len; ++i)
94 const label newIdx = oldToNew[i];
122 template<
class ListType>
126 ListType& inputOutput,
136 const ListType&
input = inputOutput;
137 const label len =
input.size();
143 for (label i=0; i < len; ++i)
145 const label newIdx = oldToNew[i];
169 inputOutput.transfer(
output);
173 template<
unsigned W
idth>
177 const PackedList<Width>&
input,
181 const label len =
input.size();
183 PackedList<Width>
output(len);
186 for (label i=0; i < len; ++i)
188 const auto& val =
input.get(i);
190 const label newIdx = oldToNew[i];
223 template<
unsigned W
idth>
238 template<
class Container>
247 for (
auto iter =
input.begin(); iter !=
input.end(); ++iter)
249 const label oldIdx = iter.key();
255 output.insert(oldToNew[oldIdx], iter.val());
263 template<
class Container>
272 for (
auto iter =
input.begin(); iter !=
input.end(); ++iter)
274 const label oldIdx = iter.val();
280 const label newIdx = oldToNew[oldIdx];
282 if (oldIdx != newIdx)
294 template<
class Container>
297 const Map<label>& mapper,
308 for (
auto iter =
input.begin(); iter !=
input.end(); ++iter)
310 label& value = iter.val();
312 auto mapIter = mapper.find(value);
313 if (mapIter.found() && value != *mapIter)
327 const UList<T>&
input
347 template<
class T,
class ListComparePredicate>
352 const ListComparePredicate& comp
367 const UList<T>&
input
387 template<
class T,
class ListComparePredicate>
392 const ListComparePredicate& comp
395 if (
input.size() < 2)
403 const label last = (order.size()-1);
405 for (label i = 0; i < last; ++i)
409 order[
count] = order[i];
420 const UList<T>&
input
440 template<
class T,
class ListComparePredicate>
445 const ListComparePredicate& comp
450 if (order.size() > 1)
452 const label last = (order.size()-1);
454 for (label i = 0; i < last; ++i)
458 order[
count++] = order[i];
461 order[
count++] = order[last];
467 template<
class ListType>
478 template<
class ListType,
class ListComparePredicate>
482 const ListComparePredicate& comp
488 const label len = order.size();
493 for (label i=0; i < len; ++i)
502 template<
class BoolListType,
class T>
505 const BoolListType& select,
506 const UList<T>&
input,
512 const label len =
input.size();
518 for (label i=0; i < len; ++i)
536 const bitSet& select,
537 const UList<T>&
input,
541 const label len =
input.size();
549 output.resize(select.count());
551 for (
const label i : select)
561 const label outlen = (select.size() - select.count());
564 for (label i=0; i < len; ++i)
570 if (
count >= outlen)
break;
581 template<
class BoolListType,
class ListType>
584 const BoolListType& select,
591 const label len =
input.size();
595 for (label i=0; i < len; ++i)
611 template<
class ListType>
625 const label len =
input.size();
627 for (
const label i : select)
642 const label outlen = (select.
size() - select.
count());
646 for (label i=0; i < len; ++i)
655 if (
count >= outlen)
break;
664 template<
class T,
class UnaryPredicate>
667 const UList<T>&
input,
668 const UnaryPredicate& pred,
672 const label len =
input.size();
677 for (label i=0; i < len; ++i)
692 template<
class ListType,
class UnaryPredicate>
696 const UnaryPredicate& pred,
700 const label len =
input.size();
703 for (label i=0; i < len; ++i)
718 template<
class InputIntListType,
class OutputIntListType>
729 for (
const InputIntListType& sublist :
input)
733 sizes[sublist[idx]]++;
741 output[outi].resize(sizes[outi]);
748 const InputIntListType& sublist =
input[listi];
752 const label outi = sublist[idx];
754 output[outi][sizes[outi]++] = listi;
760 template<
class ListType>
763 const ListType&
input,
764 typename ListType::const_reference val,
768 const label len =
input.size();
775 for (label i = start; i < len; ++i)
779 if (!
count) start = i;
790 const label total =
count;
792 for (label i = start; i < len; ++i)
797 if (++
count == total)
809 template<
class ListType>
812 const ListType&
input,
816 const label len =
input.size();
818 if (start < 0 || start >= len)
823 for (label i = start+1; i < len; ++i)
835 template<
class ListType>
838 const ListType&
input,
842 const label len =
input.size();
844 if (start < 0 || start >= len)
849 for (label i = start+1; i < len; ++i)
861 template<
class ListType>
864 const ListType&
input,
868 const label len =
input.size();
870 if (start < 0 || start >= len)
875 label minIdx = start;
876 label maxIdx = start;
878 for (label i = start+1; i < len; ++i)
894 template<
class ListType>
897 const ListType&
input,
898 typename ListType::const_reference val,
903 label high =
input.size() - 1;
905 if (start < 0 || start >=
input.size())
912 const label mid = (low + high)/2;
914 if (val <
input[mid])
918 else if (
input[mid] < val)
932 template<
class ListType,
class T,
class ComparePredicate>
935 const ListType&
input,
938 const ComparePredicate& comp
942 label high =
input.size() - 1;
944 if (start < 0 || start >=
input.size())
949 while ((high - low) > 1)
951 const label mid = (low + high)/2;
953 if (comp(
input[mid], val))
963 if (comp(
input[high], val))
967 else if (comp(
input[low], val))
978 template<
class ListType,
class T>
981 const ListType&
input,
996 template<
class ListType>
999 const label len =
input.size();
1000 const label last = (len - 1);
1005 for (label i=0; i < len; ++i)
1014 template<
class ListType>
1017 const label len =
input.size();
1018 const label last = (len - 1);
1019 const label n2 = len >> 1;
1021 for (label i=0; i<n2; ++i)
1028 template<
class ListType>
1031 const label len =
input.size();
1036 for (label i=0; i<len; ++i)
1038 label index = (i -
n) % len;
1052 template<
template<
typename>
class ListType,
class DataType>
1055 const label len =
input.size();
1057 n = (len -
n) % len;
1085 label len =
x.size();
1088 x.resize(len +
y.size());
1089 for (
const T& val :
y)
1113 for (
const T& val :
y)
1129 template<
class ListType,
class UnaryPredicate>
1132 const ListType&
input,
1133 const UnaryPredicate& pred,
1137 const label len =
input.size();
1141 for (label i = start; i < len; ++i)
1154 template<
class ListType,
class UnaryPredicate>
1157 const ListType&
input,
1158 const UnaryPredicate& pred,
1166 template<
class ListType,
class UnaryPredicate>
1169 const ListType&
input,
1170 const UnaryPredicate& pred,
1174 const label len =
input.size();
1181 for (label i = start; i < len; ++i)
1185 if (!
count) start = i;
1196 const label total =
count;
1198 for (label i = start; i < len; ++i)
1203 if (++
count == total)
1223 const label len = list.
size();
1225 for (
const label index : locations)
1228 if (index >= 0 && index < len)
1244 const label len = list.
size();
1246 for (
const label index : locations)
1249 if (index >= 0 && index < len)
1265 const label len = list.
size();
1270 for (label index = 0; index <
end; ++index)
1272 if (locations[index])
1288 const label len = list.
size();
1302 template<
class T,
class T2,
class UnaryOperation>
1306 const UnaryOperation& op
1309 const label len =
input.size();
1318 for (label i = 0; i < len; ++i)
1328 template<
class T,
class InputIterator,
class UnaryOperation>
1331 InputIterator first,
1333 const UnaryOperation& op
1344 while (first != last)
1365 List<T> list(len, deflt);
1381 List<T> list(len, deflt);
1392 const UList<bool>& locations,
1397 List<T> list(len, deflt);
1408 const bitSet& locations,
1413 List<T> list(len, deflt);
1429 List<T> list(len, deflt);
1432 if (index >= 0 && index < len)
1450 List<T> list(len, deflt);
1453 if (index >= 0 && index < len)
1455 list[index] = std::move(val);
List< label > labelList
A List of labels.
label find_first() const
Locate the first bit that is set.
void Swap(DynamicList< T, SizeMinA > &a, DynamicList< T, SizeMinB > &b)
static Ostream & output(Ostream &os, const IntRange< T > &range)
void inplaceSubsetList(ListType &input, const UnaryPredicate &pred, const bool invert=false)
Inplace subset of the list when predicate is true.
void inplaceReverseList(ListType &input)
Inplace reversal of a list using Swap.
labelList uniqueOrder(const UList< T > &input)
Return (sorted) indices corresponding to unique list values.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void resize(const label len)
Adjust allocated size of list.
static constexpr const zero Zero
Global zero (0)
static bool less(const vector &x, const vector &y)
To compare normals.
A List obtained as a section of another List.
List< T > create(const UList< T2 > &input, const UnaryOperation &op)
Create a List from a List of a dissimilar type, using the entire list.
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 inplaceRotateList(ListType< DataType > &list, label n)
Inplace reversal of a list using the Reversal Block Swapping algorithm.
void inplaceUniqueSort(ListType &input)
Inplace sorting and removal of duplicates.
List< T > createWithValue(const label len, const labelUList &locations, const T &val, const T &deflt=T())
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
unsigned int count(const bool on=true) const
Count number of bits set.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values (not the indices) of a list.
#define forAll(list, i)
Loop across all elements in list.
void stableSort(UList< T > &a)
void invertManyToMany(const label len, const UList< InputIntListType > &input, List< OutputIntListType > &output)
Invert many-to-many.
Pair< label > labelPair
A pair of labels.
labelPair findMinMax(const ListType &input, label start=0)
labelList findIndices(const ListType &input, const UnaryPredicate &pred, label start=0)
Linear search to find all occurences of given element.
void inplaceMapKey(const labelUList &oldToNew, Container &input)
Rewrite with mapped keys. Ignore elements with negative key.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
Reorder the elements of a list.
A list compare binary predicate for normal sort.
label findSortedIndex(const ListType &input, typename ListType::const_reference val, const label start=0)
label inplaceMapValue(const labelUList &oldToNew, Container &input)
Map values. Ignore negative values.
labelList duplicateOrder(const UList< T > &input)
Return (sorted) indices corresponding to duplicate list values.
label find_next(label pos) const
Locate the next bit set, starting one beyond the specified position.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Find index of the first occurrence that satisfies the predicate.
ListType rotateList(const ListType &list, const label n)
Rotate a list by n places.
List helper to append y unique elements onto the end of x.
void inplaceSubset(const BoolListType &select, ListType &input, const bool invert=false)
Inplace extract elements of the input list when select is true.
scalar distance(const vector &p1, const vector &p2)
List helper to append y elements onto the end of x.
ListType reverseList(const ListType &input)
Reverse a list. First element becomes last element etc.
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values (not the indices) of a list.
#define List_CONST_ACCESS(type, f, fp)
void setValue(UList< T > &list, const labelUList &locations, const T &val)
Set various locations of the list with a specified value.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
label findMax(const ListType &input, label start=0)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
label size() const noexcept
Number of entries.
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
void clear()
Clear the list, i.e. set size to zero.
static Istream & input(Istream &is, IntRange< T > &range)
bool found(const ListType &input, const UnaryPredicate &pred, const label start=0)
True if there is a value in the list that satisfies the predicate.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
Various functions to operate on Lists.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
void size(const label n)
Older name for setAddressableSize.
UList< label > labelUList
A UList of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
#define List_ACCESS(type, f, fp)
label findMin(const ListType &input, label start=0)
Macros for accessing List elements.
dimensionedScalar pos(const dimensionedScalar &ds)
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.