refs #108, added find methods in CSequence and CCollection;

CSequence uses std::find, and CCollection uses the more efficient find method of the implementation type,
which requires that the implementation type be an associative container like QSet or std::set.
Modified CContainerBase::contains to use these new find methods.
This commit is contained in:
Mathew Sutcliffe
2014-01-28 18:25:14 +00:00
parent d073681630
commit 1e153b45f0
5 changed files with 35 additions and 16 deletions

View File

@@ -7,8 +7,10 @@
#include "blackmisc/collection.h"
#include "blackmisc/sequence.h"
#include <QList>
#include <QString>
#include <QVector>
#include <QSet>
#include <vector>
#include <set>
using namespace BlackMisc;
@@ -19,9 +21,9 @@ namespace BlackMiscTest
{
CCollection<int> c1;
QVERIFY2(c1.empty(), "Uninitialized collection is empty");
auto c2 = CCollection<int>::fromImpl(QList<int>());
auto c2 = CCollection<int>::fromImpl(QSet<int>());
QVERIFY2(c1 == c2, "Uninitialized and empty collections are equal");
c1.changeImpl(std::vector<int>());
c1.changeImpl(std::set<int>());
QVERIFY2(c1 == c2, "Two empty collections are equal");
c1.insert(1);
QVERIFY2(c1 != c2, "Different collections are not equal");