Various utility functions to work on Lists. More...
Classes | |
struct | appendEqOp |
List helper to append y elements onto the end of x. More... | |
struct | greater |
A list compare binary predicate for reverse sort. More... | |
struct | less |
A list compare binary predicate for normal sort. More... | |
struct | unionEqOp |
List helper to add y unique elements to x. More... | |
struct | uniqueEqOp |
List helper to append y unique elements onto the end of x. More... | |
Functions | |
void | identity (labelUList &map, label start=0) |
Set identity map with (map[i] == i) More... | |
template<class ListType , class UnaryPredicate > | |
label | count_if (const ListType &input, const UnaryPredicate &pred, const label start=0) |
Count the number of matching entries. More... | |
template<class ListType , class UnaryPredicate > | |
label | find_if (const ListType &input, const UnaryPredicate &pred, const label start=0) |
Find index of the first occurrence that satisfies the predicate. More... | |
template<class ListType , class UnaryPredicate > | |
label | find (const ListType &input, const UnaryPredicate &pred, const label start=0) |
Same as ListOps::find_if. More... | |
template<class ListType , class UnaryPredicate > | |
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. More... | |
template<class ListType , class UnaryPredicate > | |
bool | found (const ListType &input, const UnaryPredicate &pred, const label start=0) |
Same as found_if. More... | |
template<class ListType , class UnaryPredicate > | |
labelList | findIndices (const ListType &input, const UnaryPredicate &pred, label start=0) |
Linear search to find all occurences of given element. More... | |
template<class T > | |
void | setValue (UList< T > &list, const labelUList &locations, const T &val) |
Set various locations of the list with a specified value. More... | |
template<class T > | |
void | setValue (UList< T > &list, const labelHashSet &locations, const T &val) |
Set various locations of the list with a specified value. More... | |
template<class T > | |
void | setValue (UList< T > &list, const UList< bool > &locations, const T &val) |
Set various locations of the list with a specified value. More... | |
template<class T > | |
void | setValue (UList< T > &list, const bitSet &locations, const T &val) |
Set various locations of the list with a specified value. More... | |
template<class T , class T2 , class UnaryOperation > | |
List< T > | create (const UList< T2 > &input, const UnaryOperation &op) |
Create a List from a List of a dissimilar type, using the entire list. More... | |
template<class T , class InputIterator , class UnaryOperation > | |
List< T > | create (InputIterator first, InputIterator last, const UnaryOperation &op) |
Create a List from an iterator range [first,last) of a dissimilar type. More... | |
template<class T > | |
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. More... | |
template<class T > | |
List< T > | createWithValue (const label len, const labelHashSet &locations, const T &val, const T &deflt=T()) |
Create a List filled with default values and various locations with another specified value. More... | |
template<class T > | |
List< T > | createWithValue (const label len, const UList< bool > &locations, const T &val, const T &deflt=T()) |
Create a List filled with default values and various locations with another specified value. More... | |
template<class T > | |
List< T > | createWithValue (const label len, const bitSet &locations, const T &val, const T &deflt=T()) |
Create a List filled with default values and various locations with another specified value. More... | |
template<class T > | |
List< T > | createWithValue (const label len, const label index, const T &val, const T &deflt=T()) |
Create a List filled with default values and one specified value, which is copy assigned at the specified index. More... | |
template<class T > | |
List< T > | createWithValue (const label len, const label index, T &&val, const T &deflt=T()) |
Create a List filled with default values and one specified value, which is move assigned at the specified index. More... | |
void identity | ( | labelUList & | map, |
label | start = 0 |
||
) |
Set identity map with (map[i] == i)
Optionally with an alternative start index, so that (map[i] == i+start)
Definition at line 196 of file ListOps.C.
References UList< T >::begin(), and UList< T >::end().
Referenced by SortableList< T >::partialReverseSort(), SortableList< T >::partialSort(), SortList< T >::reset(), and SortList< T >::sort().
label Foam::ListOps::count_if | ( | const ListType & | input, |
const UnaryPredicate & | pred, | ||
const label | start = 0 |
||
) |
Count the number of matching entries.
When start is specified, any occurrences before start are ignored. Linear search. Like std::count_if but works with list indexing
label Foam::ListOps::find_if | ( | const ListType & | input, |
const UnaryPredicate & | pred, | ||
const label | start = 0 |
||
) |
Find index of the first occurrence that satisfies the predicate.
When start is specified, any occurrences before start are ignored. Linear search. Like std::find_if but works with list indexing.
Referenced by find(), found_if(), and Foam::MatrixTools::pinv().
label Foam::ListOps::find | ( | const ListType & | input, |
const UnaryPredicate & | pred, | ||
const label | start = 0 |
||
) |
Same as ListOps::find_if.
Definition at line 790 of file ListOps.H.
References find_if(), and Foam::input().
Referenced by distribution::add(), HashTable< const regIOobject * >::at(), IOstreamOption::compressionEnum(), IndirectListBase< T, labelRange >::contains(), scalars::contains(), CircularBuffer< T >::contains(), string::contains(), FixedList< point, 2 >::contains(), UList< Foam::vector >::contains(), face::edgeDirection(), HashPtrTable< exprResult >::erase(), HashTable< const regIOobject * >::erase(), objectRegistry::erase(), Enum< actionType >::get(), isoSurfaceParams::getFilterType(), Enum< actionType >::getOrDefault(), Enum< actionType >::lookup(), HashTable< const regIOobject * >::operator()(), Enum< actionType >::read(), Enum< actionType >::readEntry(), HashPtrTable< exprResult >::release(), HashPtrTable< exprResult >::remove(), string::removeRepeated(), string::replace(), string::replaceAll(), regExpPosix::search(), cellTable::setName(), simpleObjectRegistry::setNamedValue(), simpleObjectRegistry::setValues(), and Enum< actionType >::write().
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.
When start is specified, any occurrences before start are ignored. Linear search.
Definition at line 1160 of file ListOpsTemplates.C.
References find_if(), and Foam::input().
Referenced by found().
bool Foam::ListOps::found | ( | const ListType & | input, |
const UnaryPredicate & | pred, | ||
const label | start = 0 |
||
) |
Same as found_if.
Definition at line 821 of file ListOps.H.
References found_if(), and Foam::input().
Referenced by starcdWriter::write(), writeObjects::write(), areaWrite::write(), and starcdWriter::writeTemplate().
labelList Foam::ListOps::findIndices | ( | const ListType & | input, |
const UnaryPredicate & | pred, | ||
label | start = 0 |
||
) |
Linear search to find all occurences of given element.
void setValue | ( | UList< T > & | list, |
const labelUList & | locations, | ||
const T & | val | ||
) |
Set various locations of the list with a specified value.
list | the list to modify |
locations | where to apply the specified value An out-of-range index is silently ignored. |
val | the value to set at the specified locations |
Definition at line 1221 of file ListOpsTemplates.C.
References UList< T >::size().
void setValue | ( | UList< T > & | list, |
const labelHashSet & | locations, | ||
const T & | val | ||
) |
Set various locations of the list with a specified value.
list | the list to modify |
locations | where to apply the specified value An out-of-range index is silently ignored. |
val | the value to set at the specified locations |
Definition at line 1242 of file ListOpsTemplates.C.
References UList< T >::size().
Set various locations of the list with a specified value.
list | the list to modify |
locations | where to apply the specified value An out-of-range index is silently ignored. |
val | the value to set at the specified locations |
Definition at line 1263 of file ListOpsTemplates.C.
References Foam::BitOps::count(), stdFoam::end(), Foam::min(), and UList< T >::size().
Set various locations of the list with a specified value.
list | the list to modify |
locations | where to apply the specified value An out-of-range index is silently ignored. |
val | the value to set at the specified locations |
Definition at line 1286 of file ListOpsTemplates.C.
References bitSet::find_first(), bitSet::find_next(), Foam::pos(), and UList< T >::size().
List<T> Foam::ListOps::create | ( | InputIterator | first, |
InputIterator | last, | ||
const UnaryOperation & | op | ||
) |
Create a List from an iterator range [first,last) of a dissimilar type.
Uses std::distance for the size.
first | the begin of the iterator range |
last | the end of the iterator range |
op | the unary conversion operator, which can be used to convert to other types. |
List<T> Foam::ListOps::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.
len | the length of the list |
locations | where to apply the specified value An out-of-range index is silently ignored. |
val | the value to set at the specified locations |
deflt | the initialization default value |
List<T> Foam::ListOps::createWithValue | ( | const label | len, |
const labelHashSet & | locations, | ||
const T & | val, | ||
const T & | deflt = T() |
||
) |
Create a List filled with default values and various locations with another specified value.
len | the length of the list |
locations | where to apply the specified value An out-of-range index is silently ignored. |
val | the value to set at the specified locations |
deflt | the initialization default value |
List<T> Foam::ListOps::createWithValue | ( | const label | len, |
const UList< bool > & | locations, | ||
const T & | val, | ||
const T & | deflt = T() |
||
) |
Create a List filled with default values and various locations with another specified value.
len | the length of the list |
locations | where to apply the specified value An out-of-range index is silently ignored. |
val | the value to set at the specified locations |
deflt | the initialization default value |
List<T> Foam::ListOps::createWithValue | ( | const label | len, |
const bitSet & | locations, | ||
const T & | val, | ||
const T & | deflt = T() |
||
) |
Create a List filled with default values and various locations with another specified value.
len | the length of the list |
locations | where to apply the specified value An out-of-range index is silently ignored. |
val | the value to set at the specified locations |
deflt | the initialization default value |
List<T> Foam::ListOps::createWithValue | ( | const label | len, |
const label | index, | ||
const T & | val, | ||
const T & | deflt = T() |
||
) |
Create a List filled with default values and one specified value, which is copy assigned at the specified index.
len | the length of the list |
index | where to apply the specified value. An out-of-range index is silently ignored. |
val | the value to copy assign at the specified index |
deflt | the initialization default value |
List<T> Foam::ListOps::createWithValue | ( | const label | len, |
const label | index, | ||
T && | val, | ||
const T & | deflt = T() |
||
) |
Create a List filled with default values and one specified value, which is move assigned at the specified index.
len | the length of the list |
index | where to apply the specified value. An out-of-range index is silently ignored. |
val | the value to move assign at the specified index |
deflt | the initialization default value |
For example,
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.