Rosetta Utilities  2014.16.56682
Public Member Functions | Private Attributes | List of all members
utility::IndirectSorter< DataContainerType, ComparatorType > Class Template Reference

Sorts a container of things indirectly. More...

#include <IndirectSorter.hh>

Public Member Functions

 IndirectSorter (DataContainerType &data, ComparatorType &comp)
 Creates a new sorter for a given data container and sorting rule. More...
 
 ~IndirectSorter ()
 
void sort (vector1< Size > &order)
 sorts a given container and returns a vector that defines the right order of the sorted data More...
 
bool operator() (int index_1, int index_2)
 compares two indexes by comparing the two referenced objects More...
 
- Public Member Functions inherited from utility::pointer::ReferenceCount
void ctor ()
 
virtual ~ReferenceCount ()
 Destructor. More...
 
Size ref_count () const
 Reference count. More...
 

Private Attributes

DataContainerType & underlying_data_
 
ComparatorType & comparator_
 

Additional Inherited Members

- Public Types inherited from utility::pointer::ReferenceCount
typedef platform::Size Size
 
typedef platform::Size size_type
 
- Protected Member Functions inherited from utility::pointer::ReferenceCount
 ReferenceCount ()
 Default constructor. More...
 
 ReferenceCount (ReferenceCount const &)
 Copy constructor. More...
 
ReferenceCountoperator= (ReferenceCount const &)
 Copy assignment. More...
 

Detailed Description

template<class DataContainerType, class ComparatorType>
class utility::IndirectSorter< DataContainerType, ComparatorType >

Sorts a container of things indirectly.

Detailed: The original vector remains untouched. The class provides a vector
with indexes that defines the order user wants

Constructor & Destructor Documentation

template<class DataContainerType , class ComparatorType >
utility::IndirectSorter< DataContainerType, ComparatorType >::IndirectSorter ( DataContainerType &  data,
ComparatorType &  comp 
)
inline

Creates a new sorter for a given data container and sorting rule.

Detailed: The given comparator must be a valid way to sort the given container,
e.g. when DataContainerType = vector1<Real> then ComparatorType must be an object that implements bool operator()(Real,Real) method
template<class DataContainerType , class ComparatorType >
utility::IndirectSorter< DataContainerType, ComparatorType >::~IndirectSorter ( )
inline

Member Function Documentation

template<class DataContainerType , class ComparatorType >
bool utility::IndirectSorter< DataContainerType, ComparatorType >::operator() ( int  index_1,
int  index_2 
)
inline

compares two indexes by comparing the two referenced objects

Detailed: returns the result of comparison between data[index_1] and data[index_2]
The result of a comparison depends on a comparator definition provided by a user
template<class DataContainerType , class ComparatorType >
void utility::IndirectSorter< DataContainerType, ComparatorType >::sort ( vector1< Size > &  order)
inline

sorts a given container and returns a vector that defines the right order of the sorted data

Member Data Documentation

template<class DataContainerType , class ComparatorType >
ComparatorType& utility::IndirectSorter< DataContainerType, ComparatorType >::comparator_
private
template<class DataContainerType , class ComparatorType >
DataContainerType& utility::IndirectSorter< DataContainerType, ComparatorType >::underlying_data_
private

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