Mercurial > dedupe
comparison EditDistance.hpp @ 58:7b7e84356b39
Introduce API for fine tuning inserts.
Reduce the amount of rebuilds.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Fri, 14 Sep 2012 00:04:24 +0200 |
| parents | 4c283daa42c7 |
| children | e5fa379d4030 |
comparison
equal
deleted
inserted
replaced
| 57:c8111de2e0bb | 58:7b7e84356b39 |
|---|---|
| 8 | 8 |
| 9 #include <QtCore/QHash> | 9 #include <QtCore/QHash> |
| 10 #include <QtCore/QMap> | 10 #include <QtCore/QMap> |
| 11 #include <QtCore/QString> | 11 #include <QtCore/QString> |
| 12 | 12 |
| 13 template<typename Value> | |
| 14 struct InsertRegulator<OrderedPair<UniqueString>, Value > | |
| 15 { | |
| 16 uint n; | |
| 17 void start() | |
| 18 { | |
| 19 n = 0; | |
| 20 HuffmanString::getSet().setAutoRebuild(false); | |
| 21 } | |
| 22 | |
| 23 static void finish() | |
| 24 { | |
| 25 HuffmanString::getSet().rebuild(); | |
| 26 HuffmanString::getSet().setAutoRebuild(true); | |
| 27 } | |
| 28 | |
| 29 void next() | |
| 30 { | |
| 31 if (++n == 2048) | |
| 32 HuffmanString::getSet().rebuild(); | |
| 33 } | |
| 34 }; | |
| 35 | |
| 13 class EditDistance { | 36 class EditDistance { |
| 14 protected: | 37 protected: |
| 15 //typedef ThreadSafeLookup<OrderedPair<QString>, int> cacheType; | |
| 16 typedef DBCache<OrderedPair<UniqueString>, int, true> cacheType; | 38 typedef DBCache<OrderedPair<UniqueString>, int, true> cacheType; |
| 17 //typedef QMap<OrderedPair<QString>, int> cacheType; | |
| 18 //typedef QHash<OrderedPair<QString>, int> cacheType; | |
| 19 public: | 39 public: |
| 20 static int Compute(QString a, QString b, bool removeDiacritics = false); | 40 static int Compute(QString a, QString b, bool removeDiacritics = false); |
| 21 static void removeDiacriticsNoCopy(QString& in); | 41 static void removeDiacriticsNoCopy(QString& in); |
| 22 static QString removeDiacritics(const QString& in); | 42 static QString removeDiacritics(const QString& in); |
| 23 | 43 |
| 24 //static cacheType cache; | |
| 25 static cacheType* cache; | 44 static cacheType* cache; |
| 26 }; | 45 }; |
| 27 | 46 |
| 28 #endif //EDITDISTANCE_HPP | 47 #endif //EDITDISTANCE_HPP |
