[Debtags-commits] [svn] r1747 - in tagcoll/2.0: . tagcoll/coll
Enrico Zini
enrico at costa.debian.org
Tue May 9 22:30:59 UTC 2006
Author: enrico
Date: Tue May 9 22:30:58 2006
New Revision: 1747
Modified:
tagcoll/2.0/ (props changed)
tagcoll/2.0/tagcoll/coll/fast.cc
tagcoll/2.0/tagcoll/coll/fast.h
tagcoll/2.0/tagcoll/coll/simple.cc
tagcoll/2.0/tagcoll/coll/simple.h
Log:
r2673 at viaza: enrico | 2006-05-09 12:43:32 -0500
Implemented removeTag in coll::Fast
Modified: tagcoll/2.0/tagcoll/coll/fast.cc
==============================================================================
--- tagcoll/2.0/tagcoll/coll/fast.cc (original)
+++ tagcoll/2.0/tagcoll/coll/fast.cc Tue May 9 22:30:58 2006
@@ -135,6 +135,20 @@
return res - tag;
}
+template<class ITEM, class TAG>
+void Fast<ITEM, TAG>::removeTag(const TAG& tag)
+{
+ typename std::map<TAG, std::set<ITEM> >::iterator itag = tags.find(tag);
+ for (typename std::set<ITEM>::const_iterator iitemset = itag->second.begin();
+ iitemset != itag->second.end(); ++iitemset)
+ {
+ typename std::map<ITEM, std::set<TAG> >::iterator iitem = items.find(*iitemset);
+ iitem->second -= tag;
+ if (iitem->second.empty())
+ items.erase(iitem);
+ }
+ tags.erase(itag);
+}
#if 0
@@ -168,15 +182,16 @@
#ifdef COMPILE_TESTSUITE
#include <tests/test-utils.h>
+#include <tagcoll/coll/simple.h>
namespace wibble {
namespace tut {
using namespace tagcoll::tests;
using namespace tagcoll::coll;
-struct tagcoll_tdbindexer_shar {
+struct tagcoll_fast_shar {
};
-TESTGRP(tagcoll_tdbindexer);
+TESTGRP(tagcoll_fast);
template<> template<>
void to::test<1>()
@@ -212,6 +227,35 @@
ensure_contains(impls, string("mushrooms"));
}
+template<> template<>
+void to::test<4>()
+{
+ std::string minusgarlic(
+ "margherita: tomato, mozzarella\n"
+ "funghi: tomato, mozzarella, mushrooms\n"
+ "rosmarino: rosemerry\n"
+ "marinara: tomato\n"
+ );
+ std::string minustomato(
+ "margherita: mozzarella\n"
+ "funghi: mozzarella, mushrooms\n"
+ "rosmarino: rosemerry\n"
+ );
+ Simple<string, string> result;
+
+ Fast<string, string> coll;
+ output_test_collection(inserter(coll));
+
+ coll.removeTag("garlic");
+ parseCollection(minusgarlic, inserter(result));
+ ensure_coll_equals(result, coll);
+
+ coll.removeTag("tomato");
+ result.clear();
+ parseCollection(minustomato, inserter(result));
+ ensure_coll_equals(result, coll);
+}
+
}
}
Modified: tagcoll/2.0/tagcoll/coll/fast.h
==============================================================================
--- tagcoll/2.0/tagcoll/coll/fast.h (original)
+++ tagcoll/2.0/tagcoll/coll/fast.h Tue May 9 22:30:58 2006
@@ -114,6 +114,8 @@
// tag1 implies tag2 if the itemset of tag1 is a subset of the itemset of
// tag2
std::set<TAG> getTagsImplying(const TAG& tag);
+
+ void removeTag(const TAG& tag);
};
}
Modified: tagcoll/2.0/tagcoll/coll/simple.cc
==============================================================================
--- tagcoll/2.0/tagcoll/coll/simple.cc (original)
+++ tagcoll/2.0/tagcoll/coll/simple.cc Tue May 9 22:30:58 2006
@@ -174,12 +174,6 @@
return coll.size();
}
-template<class T, class Tag>
-void Simple<T, Tag>::clear()
-{
- return coll.clear();
-}
-
}
}
Modified: tagcoll/2.0/tagcoll/coll/simple.h
==============================================================================
--- tagcoll/2.0/tagcoll/coll/simple.h (original)
+++ tagcoll/2.0/tagcoll/coll/simple.h Tue May 9 22:30:58 2006
@@ -143,7 +143,10 @@
/**
* Empty the collection
*/
- void clear();
+ void clear()
+ {
+ coll.clear();
+ }
};
}
More information about the Debtags-commits
mailing list