comparison EditDistance.hpp @ 16:06166d6c083b

Add configuration processing. Cache DB values Add a custom RBTree to save space. Track multiple DB connections properly. More testing. Add ValueExistsException.
author Tom Fredrik Blenning Klaussen <bfg@blenning.no>
date Tue, 28 Aug 2012 18:58:02 +0200
parents a3834af36579
children fda70a362ed5
comparison
equal deleted inserted replaced
15:199fc63c60c1 16:06166d6c083b
1 #ifndef EDITDISTANCE_HPP 1 #ifndef EDITDISTANCE_HPP
2 #define EDITDISTANCE_HPP 2 #define EDITDISTANCE_HPP
3 3
4 #include "OrderedPair.hpp" 4 #include "OrderedPair.hpp"
5 #include "DBCache.hpp"
6 #include "UniqueString.hpp"
5 7
6 #include <QtCore/QString> 8 #include <QtCore/QString>
7 #include <QtCore/QMap> 9 #include <QtCore/QMap>
8 #include <QtCore/QHash> 10 #include <QtCore/QHash>
9 11
10 #include "ThreadSafeLookup.hpp" 12 #include "ThreadSafeLookup.hpp"
11 13
12 class EditDistance { 14 class EditDistance {
13 protected: 15 protected:
14 typedef ThreadSafeLookup<OrderedPair<QString>, int> cacheType; 16 //typedef ThreadSafeLookup<OrderedPair<QString>, int> cacheType;
17 typedef DBCache<OrderedPair<UniqueString>, int, true> cacheType;
15 //typedef QMap<OrderedPair<QString>, int> cacheType; 18 //typedef QMap<OrderedPair<QString>, int> cacheType;
16 //typedef QHash<OrderedPair<QString>, int> cacheType; 19 //typedef QHash<OrderedPair<QString>, int> cacheType;
17 public: 20 public:
18 static int Compute(QString a, QString b, bool removeDiacritics = false); 21 static int Compute(QString a, QString b, bool removeDiacritics = false);
19 static QString removeDiacritics(QString in); 22 static QString removeDiacritics(QString in);
20 23
21 static cacheType cache; 24 //static cacheType cache;
25 static cacheType* cache;
22 }; 26 };
23 27
24 #endif //EDITDISTANCE_HPP 28 #endif //EDITDISTANCE_HPP