Public Member Functions | Private Attributes
SortableList Class Reference

A list that is sorted upon construction or when explicitly requested with the sort() method. More...

Collaboration diagram for SortableList:
Collaboration graph
[legend]

Public Member Functions

 SortableList ()
 Null constructor, sort later (eg, after assignment or transfer) More...
 
 SortableList (const UList< T > &)
 Construct from UList, sorting immediately. More...
 
 SortableList (const Xfer< List< T > > &)
 Construct from transferred List, sorting immediately. More...
 
 SortableList (const label size)
 Construct given size. Sort later on. More...
 
 SortableList (const label size, const T &)
 Construct given size and initial value. Sort later on. More...
 
 SortableList (const SortableList< T > &)
 Construct as copy. More...
 
const labelListindices () const
 Return the list of sorted indices. Updated every sort. More...
 
labelListindices ()
 Return non-const access to the sorted indices. Updated every sort. More...
 
void clear ()
 Clear the list and the indices. More...
 
List< T > & shrink ()
 Clear the indices and return a reference to the underlying List. More...
 
void sort ()
 (stable) sort the list (if changed after construction time) More...
 
void reverseSort ()
 Reverse (stable) sort the list. More...
 
Xfer< List< T > > xfer ()
 Transfer contents to the Xfer container as a plain List. More...
 
void operator= (const T &)
 Assignment of all entries to the given value. More...
 
void operator= (const UList< T > &)
 Assignment from UList operator. Takes linear time. More...
 
void operator= (const SortableList< T > &)
 Assignment operator. Takes linear time. More...
 

Private Attributes

labelList indices_
 Original indices. More...
 

Detailed Description

A list that is sorted upon construction or when explicitly requested with the sort() method.

Uses the Foam::stableSort() algorithm.

Source files

Definition at line 65 of file List.H.

Constructor & Destructor Documentation

◆ SortableList() [1/6]

Null constructor, sort later (eg, after assignment or transfer)

Definition at line 31 of file SortableList.C.

◆ SortableList() [2/6]

SortableList ( const UList< T > &  )
explicit

Construct from UList, sorting immediately.

◆ SortableList() [3/6]

SortableList ( const Xfer< List< T > > &  )
explicit

Construct from transferred List, sorting immediately.

◆ SortableList() [4/6]

SortableList ( const label  size)
explicit

Construct given size. Sort later on.

The indices remain empty until the list is sorted

Definition at line 54 of file SortableList.C.

◆ SortableList() [5/6]

SortableList ( const label  size,
const T  
)

Construct given size and initial value. Sort later on.

The indices remain empty until the list is sorted

◆ SortableList() [6/6]

SortableList ( const SortableList< T > &  )

Construct as copy.

Member Function Documentation

◆ indices() [1/2]

const labelList& indices ( ) const
inline

◆ indices() [2/2]

labelList& indices ( )
inline

Return non-const access to the sorted indices. Updated every sort.

Definition at line 96 of file SortableList.H.

References SortableList::indices_.

◆ clear()

void clear ( )

Clear the list and the indices.

Definition at line 79 of file SortableList.C.

References List::clear().

Here is the call graph for this function:

◆ shrink()

Foam::List< T > & shrink ( )

Clear the indices and return a reference to the underlying List.

Definition at line 87 of file SortableList.C.

References List::clear().

Referenced by List< substance >::transfer().

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

◆ sort()

void sort ( )

◆ reverseSort()

void reverseSort ( )

Reverse (stable) sort the list.

Definition at line 110 of file SortableList.C.

References forAll, Foam::sortedOrder(), and List::transfer().

Referenced by main().

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

◆ xfer()

Foam::Xfer< Foam::List< T > > xfer ( )
inline

Transfer contents to the Xfer container as a plain List.

Definition at line 125 of file SortableList.C.

◆ operator=() [1/3]

void operator= ( const T )
inline

Assignment of all entries to the given value.

◆ operator=() [2/3]

void operator= ( const UList< T > &  )
inline

Assignment from UList operator. Takes linear time.

◆ operator=() [3/3]

void operator= ( const SortableList< T > &  )
inline

Assignment operator. Takes linear time.

Field Documentation

◆ indices_

labelList indices_
private

Original indices.

Definition at line 59 of file SortableList.H.

Referenced by SortableList::indices().


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