Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::TopNI< T > Class Template Reference

#include <TopNI.h>

Collaboration diagram for PLearn::TopNI< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TopNI ()
 Default constructor, you must then call init.

 TopNI (int the_N)
 N is the number of (value,index) pairs to remember.

void init (int the_N)
 N is the number of (value,point) pairs to remember.

void reset ()
void update (T value, int index)
 call this for each new value seen

void sort ()
const TVec< pair< T, int > > & getTopN ()
 call this at the end to get the the smallest N values with associated integer index


Protected Attributes

int N
TVec< pair< T, int > > topn
pair< T, int > * topnptr
 topn.data()

pair< T, int > * minpair

Detailed Description

template<class T>
class PLearn::TopNI< T >

This is a very simple class, that allows you to keep track of the top N values encountered among many and their associated integer index (or corresponding position). For keeping track of the bottom N values, see the companion class BottomNI.

Definition at line 62 of file TopNI.h.


Constructor & Destructor Documentation

template<class T>
PLearn::TopNI< T >::TopNI  )  [inline]
 

Default constructor, you must then call init.

Definition at line 73 of file TopNI.h.

template<class T>
PLearn::TopNI< T >::TopNI int  the_N  )  [inline]
 

N is the number of (value,index) pairs to remember.

Definition at line 77 of file TopNI.h.

References PLearn::TopNI< T >::init().


Member Function Documentation

template<class T>
const TVec< pair<T,int> >& PLearn::TopNI< T >::getTopN  )  [inline]
 

call this at the end to get the the smallest N values with associated integer index

Definition at line 121 of file TopNI.h.

References PLearn::TopNI< T >::topn.

Referenced by PLearn::VMatrix::evaluateKernelTopN().

template<class T>
void PLearn::TopNI< T >::init int  the_N  )  [inline]
 

N is the number of (value,point) pairs to remember.

< reserve space for N elements

< set length back to 0

< ptr for faster access

Definition at line 80 of file TopNI.h.

References PLearn::TVec< pair< T, int > >::data(), PLearn::TopNI< T >::init(), PLearn::TopNI< T >::N, PLearn::TVec< pair< T, int > >::resize(), PLearn::TopNI< T >::topn, and PLearn::TopNI< T >::topnptr.

Referenced by PLearn::TopNI< T >::init(), and PLearn::TopNI< T >::TopNI().

template<class T>
void PLearn::TopNI< T >::reset  )  [inline]
 

Definition at line 88 of file TopNI.h.

References PLearn::TopNI< T >::N.

template<class T>
void PLearn::TopNI< T >::sort  )  [inline]
 

Definition at line 117 of file TopNI.h.

References PLearn::TVec< pair< T, int > >::length(), PLearn::TopNI< T >::topn, and PLearn::TopNI< T >::topnptr.

Referenced by PLearn::VMatrix::evaluateKernelTopN().

template<class T>
void PLearn::TopNI< T >::update value,
int  index
[inline]
 

call this for each new value seen

find the new minimum:

Definition at line 91 of file TopNI.h.

References PLearn::TVec< pair< T, int > >::append(), PLearn::TVec< pair< T, int > >::length(), PLearn::TopNI< T >::minpair, PLearn::TopNI< T >::N, PLearn::TopNI< T >::topn, and PLearn::TopNI< T >::topnptr.

Referenced by PLearn::VMatrix::evaluateKernelTopN().


Member Data Documentation

template<class T>
pair<T,int>* PLearn::TopNI< T >::minpair [protected]
 

Definition at line 68 of file TopNI.h.

Referenced by PLearn::TopNI< T >::update().

template<class T>
int PLearn::TopNI< T >::N [protected]
 

Definition at line 65 of file TopNI.h.

Referenced by PLearn::TopNI< T >::init(), PLearn::TopNI< T >::reset(), and PLearn::TopNI< T >::update().

template<class T>
TVec< pair<T,int> > PLearn::TopNI< T >::topn [protected]
 

Definition at line 66 of file TopNI.h.

Referenced by PLearn::TopNI< T >::getTopN(), PLearn::TopNI< T >::init(), PLearn::TopNI< T >::sort(), and PLearn::TopNI< T >::update().

template<class T>
pair<T,int>* PLearn::TopNI< T >::topnptr [protected]
 

topn.data()

Definition at line 67 of file TopNI.h.

Referenced by PLearn::TopNI< T >::init(), PLearn::TopNI< T >::sort(), and PLearn::TopNI< T >::update().


The documentation for this class was generated from the following file:
Generated on Tue Aug 17 16:24:05 2004 for PLearn by doxygen 1.3.7