source: trunk/c++_tools/classifier/FeatureSelector.cc @ 624

Last change on this file since 624 was 624, checked in by Peter, 15 years ago

fixes #109 and #110

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 1019 bytes
Line 
1// $Id$
2
3#include "FeatureSelector.h"
4
5#include "MatrixLookup.h"
6#include "MatrixLookupWeighted.h"
7
8#include <list>
9
10namespace theplu {
11namespace classifier {
12
13
14  FeatureSelector::FeatureSelector(size_t N, size_t first)
15    : first_(first), N_(N)
16  {
17  }
18
19
20  FeatureSelector::~FeatureSelector()
21  {
22    for (std::list<const MatrixLookup*>::iterator i=garbage_.begin(); 
23         i!=garbage_.end(); ++i)
24      delete *i;
25    for (std::list<const MatrixLookupWeighted*>::iterator i=
26           garbage_weighted_.begin(); i!=garbage_weighted_.end(); ++i)
27      delete *i;
28  }
29
30
31  const MatrixLookup& FeatureSelector::get(const MatrixLookup& matrix)
32  {
33    garbage_.push_back(new MatrixLookup(matrix,features_,true));
34    return *garbage_.back();
35  }
36
37
38  const MatrixLookupWeighted& 
39  FeatureSelector::get(const MatrixLookupWeighted& matrix)
40  {
41    garbage_weighted_.push_back(new MatrixLookupWeighted(matrix,features_,
42                                                         true));
43    return *garbage_weighted_.back();
44  }
45
46} // end of namespace classifier
47} // end of namespace theplu
Note: See TracBrowser for help on using the repository browser.