PLearn 0.1
|
#include <TopNI.h>
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 |
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.
PLearn::TopNI< T >::TopNI | ( | ) | [inline] |
PLearn::TopNI< T >::TopNI | ( | int | the_N | ) | [inline] |
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.
Referenced by PLearn::evaluateKernelTopN().
{ return topn; }
void PLearn::TopNI< T >::init | ( | int | the_N | ) | [inline] |
void PLearn::TopNI< T >::reset | ( | ) | [inline] |
void PLearn::TopNI< T >::sort | ( | ) | [inline] |
void PLearn::TopNI< T >::update | ( | T | value, |
int | index | ||
) | [inline] |
call this for each new value seen
find the new minimum:
Definition at line 91 of file TopNI.h.
Referenced by PLearn::evaluateKernelTopN().
{ int l=topn.length(); if(l<N) { topn.append( pair<T,int>(value,index) ); if (l==0 || value<minpair->first) minpair = &topnptr[l]; } else if(value>minpair->first) { minpair->first = value; minpair->second = index; pair<T,int>* it = topnptr; int n = N; while(n--) { if(it->first<minpair->first) minpair = it; ++it; } } }
pair<T,int>* PLearn::TopNI< T >::minpair [protected] |
int PLearn::TopNI< T >::N [protected] |
TVec< pair<T,int> > PLearn::TopNI< T >::topn [protected] |
pair<T,int>* PLearn::TopNI< T >::topnptr [protected] |