CMatchBookKeeper.cxx
Go to the documentation of this file.
1 #include "CMatchBookKeeper.h"
2 
3 namespace cmtool {
4 
6  {
7  Reset();
8  }
9 
11  {
12  _register.clear();
13  }
14 
15  void CMatchBookKeeper::Match(const std::vector<unsigned int>& matched_indexes,
16  const float& score)
17  {
18  _register.insert(std::make_pair(score,matched_indexes));
19  }
20 
21 
22  std::vector<std::vector<unsigned int> > CMatchBookKeeper::GetResult() const
23  {
24  std::vector<std::vector<unsigned int> > res;
25 
26  PassResult(res);
27 
28  return res;
29 
30  }
31 
32  /// Method to pass result
33  void CMatchBookKeeper::PassResult(std::vector<std::vector<unsigned int> >& result) const
34  {
35  result.clear();
36 
37  // Rough guess: assume half of registered pairs are good
38  result.reserve((unsigned int)(_register.size()/2));
39 
40  std::vector<bool> used_index;
41 
42  for( auto riter = _register.rbegin();
43  riter != _register.rend();
44  ++riter) {
45 
46  bool valid_set = true;
47 
48  for(auto const& index : (*riter).second) {
49 
50  if(index >= used_index.size())
51 
52  used_index.resize(index+1,false);
53 
54  else if(used_index.at(index)) valid_set = false;
55 
56  }
57 
58  if(valid_set) {
59 
60  result.push_back((*riter).second);
61 
62  for(auto& index : (*riter).second)
63 
64  used_index.at(index) = true;
65 
66  }
67 
68  }
69 
70  }
71 
72 }
Class def header for a class CMatchBookKeeper.
static QCString result
struct vector vector
void PassResult(std::vector< std::vector< unsigned int > > &result) const
Method to pass result.
CMatchBookKeeper()
Default constructor.
void Match(const std::vector< unsigned int > &matched_indexes, const float &score)
Method to register matched clusters.
std::multimap< float, std::vector< unsigned int > > _register
void Reset()
Reset method.
std::vector< std::vector< unsigned int > > GetResult() const
Method to get result.