comparison transform/TransformFactory.h @ 444:14521503f196

* Start work on TransformFinder dialog
author Chris Cannam
date Tue, 23 Sep 2008 13:39:25 +0000
parents 381ec750eeee
children aa190a6a2625
comparison
equal deleted inserted replaced
443:381ec750eeee 444:14521503f196
44 44
45 struct Match 45 struct Match
46 { 46 {
47 TransformId transform; 47 TransformId transform;
48 int score; 48 int score;
49 QStringList fragments; 49 typedef std::map<QString, QString> FragmentMap;
50 FragmentMap fragments;
50 51
51 Match() : score(0) { } 52 Match() : score(0) { }
52 Match(const Match &m) : transform(m.transform), 53 Match(const Match &m) :
53 score(m.score), fragments(m.fragments) { } 54 transform(m.transform), score(m.score), fragments(m.fragments) { }
54 55
55 bool operator<(const Match &m) { 56 bool operator<(const Match &m) const;
56 if (score != m.score) {
57 return score < m.score;
58 } else if (transform != m.transform) {
59 return transform < m.transform;
60 } else if (fragments.size() != m.fragments.size()) {
61 return fragments.size() < m.fragments.size();
62 } else {
63 for (int i = 0; i < fragments.size(); ++i) {
64 if (fragments[i] != m.fragments[i]) {
65 return fragments[i] < m.fragments[i];
66 }
67 }
68 }
69 return false;
70 }
71 }; 57 };
72 58
73 typedef std::map<TransformId, Match> SearchResults; 59 typedef std::map<TransformId, Match> SearchResults;
74 SearchResults search(QString keyword); 60 SearchResults search(QString keyword);
75 SearchResults search(QStringList keywords); 61 SearchResults search(QStringList keywords);