PLearn 0.1
Public Types | Public Member Functions | Private Attributes
PLearn::SelectedIndicesCmp< T > Class Template Reference

#include <TMat_sort.h>

Collaboration diagram for PLearn::SelectedIndicesCmp< T >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef T first_argument_type
typedef T second_argument_type
typedef bool result_type

Public Member Functions

 SelectedIndicesCmp (TVec< int > the_indices, bool use_lexical_less_than=true)
bool operator() (const T &x, const T &y)

Private Attributes

TVec< intindices
bool use_less_than

Detailed Description

template<class T>
class PLearn::SelectedIndicesCmp< T >

Definition at line 58 of file TMat_sort.h.


Member Typedef Documentation

template<class T>
typedef T PLearn::SelectedIndicesCmp< T >::first_argument_type

Definition at line 65 of file TMat_sort.h.

template<class T>
typedef bool PLearn::SelectedIndicesCmp< T >::result_type

Definition at line 67 of file TMat_sort.h.

template<class T>
typedef T PLearn::SelectedIndicesCmp< T >::second_argument_type

Definition at line 66 of file TMat_sort.h.


Constructor & Destructor Documentation

template<class T>
PLearn::SelectedIndicesCmp< T >::SelectedIndicesCmp ( TVec< int the_indices,
bool  use_lexical_less_than = true 
) [inline]

Definition at line 69 of file TMat_sort.h.

        :indices(the_indices), use_less_than(use_lexical_less_than)
    {}

Member Function Documentation

template<class T>
bool PLearn::SelectedIndicesCmp< T >::operator() ( const T &  x,
const T &  y 
) [inline]

Definition at line 73 of file TMat_sort.h.

References i, and n.

    {
        int n = indices.length();
        if(use_less_than) // lexical <
        {
            for(int k=0; k<n; k++)
            {
                int i = indices[k];
                if(x[i]<y[i])
                    return true;
                else if(x[i]>y[i])
                    return false;
            }
            return false;
        }
        else // lexical >
        {
            for(int k=0; k<n; k++)
            {
                int i = indices[k];
                if(x[i]>y[i])
                    return true;
                else if(x[i]<y[i])
                    return false;
            }
            return false;
        }
    }

Member Data Documentation

template<class T>
TVec<int> PLearn::SelectedIndicesCmp< T >::indices [private]

Definition at line 61 of file TMat_sort.h.

template<class T>
bool PLearn::SelectedIndicesCmp< T >::use_less_than [private]

Definition at line 62 of file TMat_sort.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines