43 for (
const label newIdx : map)
51 <<
"Inverse location " << newIdx
52 <<
" is out of range. List has size " << len
57 if (inverse[newIdx] >= 0)
60 <<
"Map is not one-to-one. At index " << i
61 <<
" element " << newIdx <<
" has already occurred\n"
62 <<
"Please use invertOneToMany instead"
85 for (
const label newIdx : map)
91 <<
"Inverse location " << newIdx
92 <<
" is out of range. List has size " << len
114 const label len = values.size();
117 inverse.reserve(len);
119 for (label i = 0 ; i < len; ++i)
124 inverse.insert(values[i], i);
134 const labelUList& map
139 for (
const label newIdx : map)
147 <<
"Inverse location " << newIdx
148 <<
" is out of range. List has size " << len
149 <<
abort(FatalError);
159 for (label i = 0; i < len; ++i)
161 inverse[i].resize(sizes[i]);
166 for (
const label newIdx : map)
170 inverse[newIdx][sizes[newIdx]++] = i;
184 const labelUList& map
189 for (
const label newIdx : map)
197 <<
"Inverse location " << newIdx
198 <<
" is out of range. List has size " << len
199 <<
abort(FatalError);
207 CompactListList<label> inverse(sizes);
210 sizes = labelList::subList(inverse.offsets(), inverse.size());
214 for (
const label newIdx : map)
218 values[sizes[newIdx]++] = i;
230 const labelUList& oldToNew,
235 const label len = input.
size();
242 label
pos = input.find_first();
244 pos = input.find_next(
pos)
247 const label newIdx = oldToNew[
pos];
270 const labelUList& oldToNew,
279void Foam::ListOps::unionEqOp::operator()
Various functions to operate on Lists.
A packed storage of objects of type <T> using an offset table for access.
const labelList & offsets() const noexcept
Return the offset table (= size()+1).
const List< T > & values() const noexcept
Return the packed values.
label size() const noexcept
The primary size (the number of rows/sublists).
void reserve(label numEntries)
Reserve space for at least the specified number of elements (not the number of buckets) and regenerat...
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
void resize(const label len)
Adjust allocated size of list.
A HashTable to objects of type <T> with a label key.
bool trim(label minpos=-1)
Trim any trailing zero elements, optionally specifying a a minimum position, below which trimming wil...
void reserve(const label numElem)
Reserve allocation space for at least this size (uses a size doubling strategy).
label size() const noexcept
Number of entries.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void set(const bitSet &bitset)
Set specified bits from another bitset.
label find_next(label pos) const
Locate the next bit set, starting one beyond the specified position.
label find_first() const
Locate the first bit that is set.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
CompactListList< label > invertOneToManyCompact(const label len, const labelUList &map)
Invert one-to-many compact map. Unmapped elements will be size 0.
dimensionedScalar pos(const dimensionedScalar &ds)
List< labelList > labelListList
List of labelList.
Map< label > invertToMap(const labelUList &values)
Create inverse mapping, which is a lookup table into the given list.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
UList< label > labelUList
A UList of labels.
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
Reorder the elements of a list.