[Debtags-commits] [svn] r1847 - in tagcoll/2.0: . tagcoll/coll
tagcoll/tests
Enrico Zini
enrico at costa.debian.org
Tue Aug 15 10:24:48 UTC 2006
Author: enrico
Date: Tue Aug 15 10:24:44 2006
New Revision: 1847
Modified:
tagcoll/2.0/ (props changed)
tagcoll/2.0/tagcoll/coll/fast.h
tagcoll/2.0/tagcoll/coll/patched.h
tagcoll/2.0/tagcoll/coll/patched.tcc
tagcoll/2.0/tagcoll/tests/test-utils.tcc
Log:
r3156 at viaza: enrico | 2006-08-15 11:24:29 +0100
Added test to ensure that clear() is implemented
Implemented clear() in fast and patched, where it was missing
Modified: tagcoll/2.0/tagcoll/coll/fast.h
==============================================================================
--- tagcoll/2.0/tagcoll/coll/fast.h (original)
+++ tagcoll/2.0/tagcoll/coll/fast.h Tue Aug 15 10:24:44 2006
@@ -82,6 +82,8 @@
template<typename ITEMS, typename TAGS>
void insert(const ITEMS& items, const TAGS& tags);
+ void clear() { items.clear(); tags.clear(); }
+
std::set<TAG> getTagsOfItem(const ITEM& item) const;
std::set<ITEM> getItemsHavingTag(const TAG& tag) const;
Modified: tagcoll/2.0/tagcoll/coll/patched.h
==============================================================================
--- tagcoll/2.0/tagcoll/coll/patched.h (original)
+++ tagcoll/2.0/tagcoll/coll/patched.h Tue Aug 15 10:24:44 2006
@@ -174,6 +174,11 @@
}
/**
+ * Removes all items from the collection
+ */
+ void clear();
+
+ /**
* Get the changes that have been applied to this collection
*/
const Patches& changes() const { return m_changes; }
Modified: tagcoll/2.0/tagcoll/coll/patched.tcc
==============================================================================
--- tagcoll/2.0/tagcoll/coll/patched.tcc (original)
+++ tagcoll/2.0/tagcoll/coll/patched.tcc Tue Aug 15 10:24:44 2006
@@ -33,6 +33,18 @@
namespace coll {
template<typename ROCOLL>
+void Patched<ROCOLL>::clear()
+{
+ // Remove all patches
+ m_changes.clear();
+
+ // Add all tagsets of the underlying collection as removed tags in the patch
+ for (typename ROCOLL::const_iterator i = coll.begin();
+ i != coll.end(); ++i)
+ m_changes.addPatch(Patch(i->first, std::set< typename coll_traits<ROCOLL>::tag_type >(), i->second));
+}
+
+template<typename ROCOLL>
typename coll_traits<ROCOLL>::itemset_type Patched<ROCOLL>::getItemsHavingTag(const Tag& tag) const
{
ItemSet items(coll.getItemsHavingTag(tag));
Modified: tagcoll/2.0/tagcoll/tests/test-utils.tcc
==============================================================================
--- tagcoll/2.0/tagcoll/tests/test-utils.tcc (original)
+++ tagcoll/2.0/tagcoll/tests/test-utils.tcc Tue Aug 15 10:24:44 2006
@@ -487,6 +487,13 @@
inner_ensure_contains(tagset, string("tag2"));
inner_ensure_contains(tagset, string("tag3"));
inner_ensure_not_contains(tagset, string("tag4"));
+
+ // Ensure that clear() is implemented
+ tc.clear();
+ itemset = tc.getTaggedItems();
+ inner_ensure(itemset.empty());
+ tagset = tc.getAllTags();
+ inner_ensure(tagset.empty());
}
}
More information about the Debtags-commits
mailing list