summaryrefslogtreecommitdiff
path: root/logbook/countriesworked.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2018-12-19 22:58:32 +0100
committerChristoph Berg <myon@debian.org>2018-12-19 22:58:32 +0100
commite0737c56c1e384e05064a0c6e1ac46979371041b (patch)
treea0123d694a2d36c43dabdf0a3907392fce11d457 /logbook/countriesworked.cpp
parentb4aebf2d137b892f53503b13785ecae900062ff7 (diff)
New upstream version 2.0.0+repackupstream/2.0.0+repack
Diffstat (limited to 'logbook/countriesworked.cpp')
-rw-r--r--logbook/countriesworked.cpp50
1 files changed, 16 insertions, 34 deletions
diff --git a/logbook/countriesworked.cpp b/logbook/countriesworked.cpp
index 6a991f8a..bcd73af7 100644
--- a/logbook/countriesworked.cpp
+++ b/logbook/countriesworked.cpp
@@ -1,42 +1,24 @@
#include "countriesworked.h"
-void CountriesWorked::init(const QStringList countryNames)
-{
- _data.clear();
- foreach(QString name,countryNames)
- _data.insert(name,false);
-}
+#include <set>
+
+#include "pimpl_impl.hpp"
-void CountriesWorked::setAsWorked(const QString countryName)
+class CountriesWorkedimpl final
{
- if (_data.contains(countryName))
- _data.insert(countryName,true);
-}
-
-bool CountriesWorked::getHasWorked(const QString countryName) const
-{
- if (_data.contains(countryName))
- return _data.value(countryName);
+public:
+ // element is country-name+band where the '+' is actual a character
+ // which allows an efficient lower_bound() search for country-name+
+ // to check for ATNOs
+ std::set<QString> worked_;
+};
- return false;
-}
-
-int CountriesWorked::getWorkedCount() const
+void CountriesWorked::add (QString const& country, QString const& band)
{
- int count = 0;
- foreach (bool value,_data)
- if (value)
- count += 1;
- return count;
-}
-
-int CountriesWorked::getSize() const
+ m_->worked_.insert (country + '+' + band);
+}
+
+bool CountriesWorked::contains (QString const& country, QString const& band) const
{
- return _data.count();
+ return m_->worked_.end () != m_->worked_.lower_bound (country + '+' + band);
}
-
-
-
-
-
-