ListOps.H File Reference

Various functions to operate on Lists. More...

Include dependency graph for ListOps.H:

Go to the source code of this file.

Classes

struct  appendEqOp< T >
 List helper to append y elements onto the end of x. More...
 
struct  uniqueEqOp< T >
 List helper to append y unique elements onto the end of x. More...
 
struct  unionEqOp
 List helper to add y unique elements to x. More...
 
struct  less< ListType >
 A list compare binary predicate for normal sort. More...
 
struct  greater< ListType >
 A list compare binary predicate for reverse sort. More...
 

Namespaces

namespace  Foam::ListOps
 Various utility functions to work on Lists.
 
namespace  Foam
 Namespace for OpenFOAM.
 

Functions

template<class IntListType >
IntListType renumber (const labelUList &oldToNew, const IntListType &input)
 Renumber the values (not the indices) of a list. More...
 
template<class IntListType >
void inplaceRenumber (const labelUList &oldToNew, IntListType &input)
 Inplace renumber the values (not the indices) of a list. More...
 
template<class ListType >
ListType reorder (const labelUList &oldToNew, const ListType &input, const bool prune=false)
 Reorder the elements of a list. More...
 
template<class ListType >
void inplaceReorder (const labelUList &oldToNew, ListType &input, const bool prune=false)
 Inplace reorder the elements of a list. More...
 
template<unsigned Width>
PackedList< Width > reorder (const labelUList &oldToNew, const PackedList< Width > &input, const bool prune=false)
 Reorder the elements of a packed list. More...
 
template<unsigned Width>
void inplaceReorder (const labelUList &oldToNew, PackedList< Width > &input, const bool prune=false)
 Inplace reorder the elements of a packed list. More...
 
bitSet reorder (const labelUList &oldToNew, const bitSet &input, const bool prune=false)
 Reorder the elements of a list. More...
 
void inplaceReorder (const labelUList &oldToNew, bitSet &input, const bool prune=false)
 Inplace reorder the elements of a list. More...
 
template<class Container >
void inplaceMapKey (const labelUList &oldToNew, Container &input)
 Rewrite with mapped keys. Ignore elements with negative key. More...
 
template<class Container >
label inplaceMapValue (const labelUList &oldToNew, Container &input)
 Map values. Ignore negative values. More...
 
template<class Container >
label inplaceMapValue (const Map< label > &mapper, Container &input)
 Use mapper as a lookup to modify the values of input. More...
 
template<class T >
labelList duplicateOrder (const UList< T > &input)
 Return (sorted) indices corresponding to duplicate list values. More...
 
template<class T >
void duplicateOrder (const UList< T > &input, labelList &order)
 Generate (sorted) indices corresponding to duplicate list values. More...
 
template<class T , class ListComparePredicate >
void duplicateOrder (const UList< T > &input, labelList &order, const ListComparePredicate &comp)
 Generate (sorted) indices corresponding to duplicate list values. More...
 
template<class T >
labelList uniqueOrder (const UList< T > &input)
 Return (sorted) indices corresponding to unique list values. More...
 
template<class T >
void uniqueOrder (const UList< T > &input, labelList &order)
 Generate (sorted) indices corresponding to unique list values. More...
 
template<class T , class ListComparePredicate >
void uniqueOrder (const UList< T > &input, labelList &order, const ListComparePredicate &comp)
 Generate (sorted) indices corresponding to unique list values. More...
 
template<class T >
List< TuniqueSort (const UList< T > &input)
 Return sorted list with removal of duplicates. More...
 
template<class ListType >
void inplaceUniqueSort (ListType &input)
 Inplace sorting and removal of duplicates. More...
 
template<class ListType , class ListComparePredicate >
void inplaceUniqueSort (ListType &input, const ListComparePredicate &comp)
 Inplace sorting and removal of duplicates. More...
 
template<class BoolListType , class T >
List< Tsubset (const BoolListType &select, const UList< T > &input, const bool invert=false)
 Extract elements of the input list when select is true. More...
 
template<class T >
List< Tsubset (const bitSet &select, const UList< T > &input, const bool invert=false)
 Extract elements of the input list when select is true. More...
 
template<class BoolListType , class ListType >
void inplaceSubset (const BoolListType &select, ListType &input, const bool invert=false)
 Inplace extract elements of the input list when select is true. More...
 
template<class ListType >
void inplaceSubset (const bitSet &select, ListType &input, const bool invert=false)
 Inplace extract elements of the input list when select is true. More...
 
template<class T , class UnaryPredicate >
List< TsubsetList (const UList< T > &input, const UnaryPredicate &pred, const bool invert=false)
 Copy a subset of the input list when predicate is true. More...
 
template<class ListType , class UnaryPredicate >
void inplaceSubsetList (ListType &input, const UnaryPredicate &pred, const bool invert=false)
 Inplace subset of the list when predicate is true. More...
 
labelList invert (const label len, const labelUList &map)
 Create an inverse one-to-one mapping. More...
 
labelList invert (const label len, const bitSet &map)
 Create an inverse one-to-one mapping for all 'on' bits of the map. More...
 
labelList invert (const bitSet &map)
 Create an inverse one-to-one mapping for all 'on' bits of the map. More...
 
labelListList invertOneToMany (const label len, const labelUList &map)
 Invert one-to-many map. Unmapped elements will be size 0. More...
 
template<class InputIntListType , class OutputIntListType >
void invertManyToMany (const label len, const UList< InputIntListType > &input, List< OutputIntListType > &output)
 Invert many-to-many. More...
 
template<class InputIntListType , class OutputIntListType >
List< OutputIntListType > invertManyToMany (const label len, const UList< InputIntListType > &input)
 
template<class ListType >
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. More...
 
template<class ListType >
labelList findIndices (const ListType &input, typename ListType::const_reference val, label start=0)
 Linear search to find all occurrences of given element. More...
 
template<class ListType >
label findMin (const ListType &input, label start=0)
 
template<class ListType >
label findMax (const ListType &input, label start=0)
 
template<class ListType >
labelPair findMinMax (const ListType &input, label start=0)
 
template<class ListType >
label findSortedIndex (const ListType &input, typename ListType::const_reference val, const label start=0)
 
template<class ListType , class T , class ComparePredicate >
label findLower (const ListType &input, const T &val, const label start, const ComparePredicate &comp)
 
template<class ListType , class T >
label findLower (const ListType &input, const T &val, const label start=0)
 
template<class ListType >
ListType reverseList (const ListType &input)
 Reverse a list. First element becomes last element etc. More...
 
template<class ListType >
void inplaceReverseList (ListType &input)
 Inplace reversal of a list using Swap. More...
 
template<class ListType >
ListType rotateList (const ListType &list, const label n)
 Rotate a list by n places. More...
 
template<template< typename > class ListType, class DataType >
void inplaceRotateList (ListType< DataType > &list, label n)
 Inplace reversal of a list using the Reversal Block Swapping algorithm. More...
 
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< Tcreate (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< Tcreate (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< TcreateWithValue (const label len, const labelUList &locations, const T &val, const T &deflt=T())
 
template<class T >
List< TcreateWithValue (const label len, const labelHashSet &locations, const T &val, const T &deflt=T())
 
template<class T >
List< TcreateWithValue (const label len, const UList< bool > &locations, const T &val, const T &deflt=T())
 
template<class T >
List< TcreateWithValue (const label len, const bitSet &locations, const T &val, const T &deflt=T())
 
template<class T >
List< TcreateWithValue (const label len, const label index, const T &val, const T &deflt=T())
 
template<class T >
List< TcreateWithValue (const label len, const label index, T &&val, const T &deflt=T())
 

Detailed Description

Various functions to operate on Lists.

Original source file ListOps.H

InNamespace Foam

Definition in file ListOps.H.