Classes | Namespaces | Functions | Variables
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

class  ListAppendEqOp< T >
 Helper class for list to append y onto the end of x. More...
 

Namespaces

 Foam
 Namespace for OpenFOAM.
 

Functions

template<class Type >
static const List< Type > & emptyList ()
 Return reference to zero-sized list. Compare to List::null() which returns. More...
 
template<class ListType >
ListType renumber (const labelUList &oldToNew, const ListType &)
 Renumber the values (not the indices) of a list. More...
 
template<class ListType >
void inplaceRenumber (const labelUList &oldToNew, ListType &)
 Inplace renumber the values of a list. More...
 
template<class ListType >
ListType reorder (const labelUList &oldToNew, const ListType &)
 Reorder the elements (indices, not values) of a list. More...
 
template<class ListType >
void inplaceReorder (const labelUList &oldToNew, ListType &)
 Inplace reorder the elements of a list. More...
 
template<class Container >
void inplaceMapValue (const labelUList &oldToNew, Container &)
 Map values. Do not map negative values. More...
 
template<class Container >
void inplaceMapKey (const labelUList &oldToNew, Container &)
 Recreate with mapped keys. Do not map elements with negative key. More...
 
template<class T >
void sortedOrder (const UList< T > &, labelList &order)
 Generate the (stable) sort order for the list. More...
 
template<class T , class Cmp >
void sortedOrder (const UList< T > &, labelList &order, const Cmp &cmp)
 
template<class T >
void duplicateOrder (const UList< T > &, labelList &order)
 Generate (sorted) indices corresponding to duplicate list values. More...
 
template<class T , class Cmp >
void duplicateOrder (const UList< T > &, labelList &order, const Cmp &cmp)
 
template<class T >
void uniqueOrder (const UList< T > &, labelList &order)
 Generate (sorted) indices corresponding to unique list values. More...
 
template<class T , class Cmp >
void uniqueOrder (const UList< T > &, labelList &order, const Cmp &cmp)
 
template<class T , class ListType >
ListType subset (const UList< T > &select, const T &value, const ListType &)
 Extract elements of List when select is a certain value. More...
 
template<class T , class ListType >
void inplaceSubset (const UList< T > &select, const T &value, ListType &)
 Inplace extract elements of List when select is a certain value. More...
 
template<class BoolListType , class ListType >
ListType subset (const BoolListType &select, const ListType &)
 Extract elements of List when select is true. More...
 
template<class BoolListType , class ListType >
void inplaceSubset (const BoolListType &select, ListType &)
 Inplace extract elements of List when select is true. More...
 
labelList invert (const label len, const labelUList &)
 Invert one-to-one map. Unmapped elements will be -1. More...
 
labelListList invertOneToMany (const label len, const labelUList &)
 Invert one-to-many map. Unmapped elements will be size 0. More...
 
template<class InList , class OutList >
void invertManyToMany (const label len, const UList< InList > &, List< OutList > &)
 Invert many-to-many. More...
 
template<class InList , class OutList >
List< OutList > invertManyToMany (const label len, const UList< InList > &in)
 
labelList identity (const label len)
 Create identity map (map[i] == i) of given length. More...
 
template<class ListType >
label findIndex (const ListType &, typename ListType::const_reference, const label start=0)
 Find first occurence of given element and return index,. More...
 
template<class ListType >
labelList findIndices (const ListType &, typename ListType::const_reference, const label start=0)
 Find all occurences of given element. Linear search. More...
 
template<class ListType >
void setValues (ListType &, const labelUList &indices, typename ListType::const_reference)
 Opposite of findIndices: set values at indices to given value. More...
 
template<class ListType >
ListType createWithValues (const label sz, typename ListType::const_reference initValue, const labelUList &indices, typename ListType::const_reference setValue)
 Opposite of findIndices: set values at indices to given value. More...
 
template<class ListType >
label findMax (const ListType &, const label start=0)
 Find index of max element (and larger than given element). More...
 
template<class ListType >
label findMin (const ListType &, const label start=0)
 Find index of min element (and less than given element). More...
 
template<class ListType >
label findSortedIndex (const ListType &, typename ListType::const_reference, const label start=0)
 Find first occurence of given element in sorted list and return index,. More...
 
template<class ListType , class BinaryOp >
label findLower (const ListType &, typename ListType::const_reference, const label stary, const BinaryOp &bop)
 Find last element < given value in sorted list and return index,. More...
 
template<class ListType >
label findLower (const ListType &, typename ListType::const_reference, const label start=0)
 Find last element < given value in sorted list and return index,. More...
 
template<class Container , class T , int nRows>
List< Container > initList (const T[nRows])
 To construct a List from a C array. Has extra Container type. More...
 
template<class Container , class T , int nRows, int nColumns>
List< Container > initListList (const T[nRows][nColumns])
 To construct a (square) ListList from a C array. Has extra Container type. More...
 
template<class ListType >
ListType reverseList (const ListType &list)
 Reverse a list. First element becomes last element etc. More...
 
template<class ListType >
void inplaceReverseList (ListType &list)
 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. If n is positive rotate clockwise/right/down. 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...
 

Variables

const labelList emptyLabelList = Foam::labelList(0)
 

Detailed Description

Various functions to operate on Lists.

Original source file ListOps.H

InNamspace Foam

Source files

Definition in file ListOps.H.