SortList< T > Class Template Reference

An indirect list with addressing based on sorting. The list is sorted upon construction or when explicitly requested. More...

Inheritance diagram for SortList< T >:
[legend]
Collaboration diagram for SortList< T >:
[legend]

Public Member Functions

 SortList (const UList< T > &values)
 Shallow copy values list reference, sort immediately. More...
 
template<class Compare >
 SortList (const UList< T > &values, const Compare &comp)
 
const labelUListindices () const noexcept
 Return the list of sorted indices (updated every sort). More...
 
labelListindices () noexcept
 Return the list of indices (updated every sort). More...
 
void reverse ()
 Reverse the indices. More...
 
void reset ()
 Reset list indices to identity. More...
 
template<class Compare >
void sort (const Compare &comp)
 Sort the list using the given value comparator. More...
 
void sort ()
 
void reverseSort ()
 
void uniqueSort ()
 Sort the list, only retaining unique entries. More...
 
- Public Member Functions inherited from IndirectList< T >
 IndirectList (const UList< T > &values, const labelUList &addr)
 Copy construct addressing, shallow copy values reference. More...
 
 IndirectList (const UList< T > &values, labelList &&addr)
 Move construct addressing, shallow copy values reference. More...
 
 IndirectList (const UList< T > &values, const Foam::zero)
 Zero-sized addressing, shallow copy values reference. More...
 
 IndirectList (const IndirectList< T > &list)
 Copy construct addressing, shallow copy values reference. More...
 
 IndirectList (IndirectList< T > &&list)
 Move construct addressing, shallow copy values reference. More...
 
 IndirectList (const UIndirectList< T > &list)
 Copy construct addressing, shallow copy values reference. More...
 
void operator= (const IndirectList< T > &rhs)
 Deep copy values, Fatal if list sizes are not identical. More...
 
template<class UnaryCondition >
Foam::IndirectList< Tsubset (const UList< T > &values, const UnaryCondition &select, const bool invert)
 
template<class UnaryPredicate >
Foam::IndirectList< Tsubset_if (const UList< T > &values, const UnaryPredicate &pred, const bool invert)
 
const Addr & addressing () const noexcept
 The list addressing. More...
 
Addr & addressing () noexcept
 The list addressing. More...
 
- Public Member Functions inherited from UIndirectList< T >
 UIndirectList (const UList< T > &values, const labelUList &addr)
 Shallow copy values and addressing. More...
 
 UIndirectList (const UIndirectList< T > &list)
 Copy construct (shallow copy values and addressing) More...
 
void operator= (const UIndirectList< T > &rhs)
 Deep copy values, Fatal if list sizes are not identical. More...
 
- Public Member Functions inherited from IndirectListBase< T, labelUList >
 IndirectListBase ()=delete
 No default construct. More...
 
 IndirectListBase (const UList< T > &values, const labelUList &addr)
 Store references to the values list and the addressing array. More...
 
label size () const noexcept
 The number of elements in the list. More...
 
bool empty () const noexcept
 True if the list is empty (ie, size() is zero). More...
 
const UList< T > & values () const noexcept
 The list of values (without addressing) More...
 
UList< T > & values () noexcept
 The list of values (without addressing) More...
 
const labelUListaddressing () const noexcept
 The addressing used for the list. More...
 
bool uniform () const
 True if all entries have identical values, and list is non-empty. More...
 
const Tfirst () const
 The first element of the list. More...
 
Tfirst ()
 The first element of the list. More...
 
const Tlast () const
 The last element of the list. More...
 
Tlast ()
 The last element of the list. More...
 
label fcIndex (const label i) const
 
label rcIndex (const label i) const
 
const TfcValue (const label i) const
 Return forward circular value (ie, next value in the list) More...
 
TfcValue (const label i)
 Return forward circular value (ie, next value in the list) More...
 
const TrcValue (const label i) const
 Return reverse circular value (ie, previous value in the list) More...
 
TrcValue (const label i)
 Return reverse circular value (ie, previous value in the list) More...
 
label find (const T &val, label pos=0) const
 Find index of the first occurrence of the value. More...
 
label rfind (const T &val, label pos=-1) const
 Find index of the last occurrence of the value. More...
 
bool found (const T &val, label pos=0) const
 True if the value if found in the list. More...
 
List< Toperator() () const
 Return the addressed elements as a List. More...
 
Toperator[] (const label i)
 Non-const access to an element in the list. More...
 
const Toperator[] (const label i) const
 Const access to an element in the list. More...
 
void operator= (const T &val)
 Assign all addressed elements to the given value. More...
 
void operator= (const Foam::zero)
 Assignment of all entries to zero. More...
 
void operator= (const UList< T > &rhs)
 Deep copy values from a list of the addressed elements. More...
 
void operator= (const IndirectListBase< T, labelUList > &rhs)
 Deep copy values from a list of the addressed elements. More...
 
void operator= (const IndirectListBase< T, AnyAddr > &rhs)
 Deep copy values from a list of the addressed elements. More...
 
iterator begin ()
 Return an iterator at begin of list. More...
 
const_iterator begin () const
 Return a const_iterator at begin of list. More...
 
iterator end ()
 Return an iterator at end of list. More...
 
const_iterator end () const
 Return a const_iterator at end of list. More...
 
const_iterator cbegin () const
 Return a const_iterator at begin of list. More...
 
const_iterator cend () const
 Return a const_iterator at end of list. More...
 
OstreamwriteList (Ostream &os, const label shortLen=0) const
 Write List, with line-breaks in ASCII when length exceeds shortLen. More...
 

Additional Inherited Members

- Public Types inherited from IndirectListBase< T, labelUList >
typedef T value_type
 Type of values the list contains. More...
 
typedef Tpointer
 The pointer type for non-const access to value_type items. More...
 
typedef const Tconst_pointer
 The pointer type for const access to value_type items. More...
 
typedef Treference
 The type used for storing into value_type objects. More...
 
typedef const Tconst_reference
 The type used for reading from constant value_type objects. More...
 
typedef label size_type
 The type to represent the size of a UList. More...
 
typedef label difference_type
 The difference between iterator objects. More...
 
typedef labelUList addressing_type
 The addressing type (non-stl definition) More...
 
- Static Public Member Functions inherited from IndirectList< T >
template<class UnaryCondition >
static IndirectList< Tsubset (const UList< T > &values, const UnaryCondition &select, const bool invert=false)
 
template<class UnaryPredicate >
static IndirectList< Tsubset_if (const UList< T > &values, const UnaryPredicate &pred, const bool invert=false)
 
static IndirectList< Tuniq (const UList< T > &values, const bool sorted=false)
 Return an IndirectList with duplicate entries filtered out. More...
 
- Protected Member Functions inherited from IndirectListBase< T, labelUList >
void copyList (const ListType &rhs)
 Deep copy values from the list. More...
 

Detailed Description

template<class T>
class Foam::SortList< T >

An indirect list with addressing based on sorting. The list is sorted upon construction or when explicitly requested.

Uses the std::stable_sort() algorithm.

Source files

Definition at line 54 of file SortList.H.

Constructor & Destructor Documentation

◆ SortList() [1/2]

SortList ( const UList< T > &  values)
inlineexplicit

Shallow copy values list reference, sort immediately.

Definition at line 33 of file SortListI.H.

References SortList< T >::sort().

Here is the call graph for this function:

◆ SortList() [2/2]

SortList ( const UList< T > &  values,
const Compare &  comp 
)
inline

Shallow copy values list reference, sort with given value comparator.

Note
The comparator is not stored in the class.

Definition at line 43 of file SortListI.H.

Member Function Documentation

◆ indices() [1/2]

const Foam::labelUList & indices
inlinenoexcept

Return the list of sorted indices (updated every sort).

Same as addressing()

Definition at line 54 of file SortListI.H.

Referenced by SprayCloud< CloudType >::penetration().

Here is the caller graph for this function:

◆ indices() [2/2]

Foam::labelList & indices
inlinenoexcept

Return the list of indices (updated every sort).

Same as addressing()

Definition at line 61 of file SortListI.H.

◆ reverse()

void reverse
inline

Reverse the indices.

Definition at line 68 of file SortListI.H.

References Foam::reverse().

Here is the call graph for this function:

◆ reset()

void reset
inline

Reset list indices to identity.

Definition at line 75 of file SortListI.H.

References Foam::ListOps::identity().

Here is the call graph for this function:

◆ sort() [1/2]

void sort ( const Compare &  comp)
inline

Sort the list using the given value comparator.

Definition at line 86 of file SortListI.H.

References b, and Foam::ListOps::identity().

Here is the call graph for this function:

◆ sort() [2/2]

void sort
inline

Forward (stable) sort the list. Functionally identical to sort with std::less<T>()

Definition at line 104 of file SortListI.H.

References Foam::sortedOrder().

Referenced by SortList< T >::SortList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reverseSort()

void reverseSort
inline

Reverse (stable) sort the list. Functionally identical to sort with std::greater<T>()

Definition at line 118 of file SortListI.H.

References Foam::sortedOrder().

Here is the call graph for this function:

◆ uniqueSort()

void uniqueSort
inline

Sort the list, only retaining unique entries.

Definition at line 111 of file SortListI.H.

References Foam::uniqueOrder().

Here is the call graph for this function:

The documentation for this class was generated from the following files: