Mercurial > dedupe
view UniqueString.hpp @ 18:fcb7a71a22c1
Make it possible to turn off asserting for the RBTree template header.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Wed, 29 Aug 2012 20:04:05 +0200 |
| parents | 06166d6c083b |
| children | d0502678429c |
line wrap: on
line source
#ifndef UNIQUESTRING_HPP #define UNIQUESTRING_HPP #if 0 #include <QtCore/QMap> #include <QtCore/QString> class UniqueString : public QString { private: static QMap<QString, QString> map; public: UniqueString(const QString& str) { if (!map.contains(str)) { map.insert(str, str); } QString::operator=(map.value(str)); } }; #else #include "RBTree.hpp" #include <QtCore/QString> #include <QtCore/QDebug> class UniqueString : public QString { private: static RBTree<QString> map; public: UniqueString(const QString& str) { boost::optional<QString> present = map.find(str); if (!present) { map.insert(str); present = str; //qDebug() << map.optimal_depth() << " : " << map.avg_depth() << " : " << map.depth(); } QString::operator=(*present); } }; #endif #endif //UNIQUESTRING_HPP
