[Debtags-commits] [svn] r1769 - in tagcoll/2.0: . tagcoll tagcoll/coll

Enrico Zini enrico at costa.debian.org
Thu May 11 13:38:41 UTC 2006


Author: enrico
Date: Thu May 11 13:38:34 2006
New Revision: 1769

Added:
   tagcoll/2.0/tagcoll/coll/base.tcc
Modified:
   tagcoll/2.0/   (props changed)
   tagcoll/2.0/tagcoll/Makefile.am
   tagcoll/2.0/tagcoll/SmartHierarchy.h
   tagcoll/2.0/tagcoll/coll/base.h
   tagcoll/2.0/tagcoll/coll/fast.h
   tagcoll/2.0/tagcoll/coll/fast.tcc
   tagcoll/2.0/tagcoll/coll/patched.tcc
   tagcoll/2.0/tagcoll/coll/simple.h
Log:
 r2717 at viaza:  enrico | 2006-05-11 07:53:55 -0500
 Split base.tcc out of base.h


Modified: tagcoll/2.0/tagcoll/Makefile.am
==============================================================================
--- tagcoll/2.0/tagcoll/Makefile.am	(original)
+++ tagcoll/2.0/tagcoll/Makefile.am	Thu May 11 13:38:34 2006
@@ -27,6 +27,7 @@
 		stream/patcher.tcc \
 		\
 		coll/base.h \
+		coll/base.tcc \
 		coll/simple.h \
 		coll/simple.tcc \
 		coll/fast.h \

Modified: tagcoll/2.0/tagcoll/SmartHierarchy.h
==============================================================================
--- tagcoll/2.0/tagcoll/SmartHierarchy.h	(original)
+++ tagcoll/2.0/tagcoll/SmartHierarchy.h	Thu May 11 13:38:34 2006
@@ -25,6 +25,7 @@
 
 #include <tagcoll/coll/base.h>
 #include <vector>
+#include <set>
 
 namespace tagcoll
 {

Modified: tagcoll/2.0/tagcoll/coll/base.h
==============================================================================
--- tagcoll/2.0/tagcoll/coll/base.h	(original)
+++ tagcoll/2.0/tagcoll/coll/base.h	Thu May 11 13:38:34 2006
@@ -24,7 +24,10 @@
  */
 
 #include <wibble/mixin.h>
-#include <tagcoll/utils/set.h>
+
+namespace std {
+template<typename A, typename B> class pair;
+}
 
 namespace tagcoll {
 namespace coll {
@@ -72,10 +75,7 @@
 	 * \return 
 	 *   true if the collection contains tag, false otherwise
 	 */
-	bool hasTag(const typename coll_traits<Self>::tag_type& tag) const
-	{
-		return !self().getItemsHavingTag(tag).empty();
-	}
+	bool hasTag(const typename coll_traits<Self>::tag_type& tag) const;
 
 	/**
 	 * Get the tags of item `item'.  Return an empty set if `item' does not exist
@@ -92,16 +92,7 @@
 	 *   exist.
 	 */
 	template<typename ITEMS>
-	typename coll_traits<Self>::tagset_type getTagsOfItems(const ITEMS& items) const
-	{
-		using namespace wibble::operators;
-		typename coll_traits<Self>::tagset_type res;
-		for (typename ITEMS::const_iterator i = items.begin();
-				i != items.end(); i++)
-			res |= self().getTagsOfItem(*i);
-		return res;
-	}
-
+	typename coll_traits<Self>::tagset_type getTagsOfItems(const ITEMS& items) const;
 
 	/**
 	 * Get the items with tag `tag'.  Return an empty set if `tag' does not exist
@@ -115,20 +106,7 @@
 	 *   The items found, or an empty set if no items have that tag
 	 */
 	template<typename TAGS>
-	typename coll_traits<Self>::itemset_type getItemsHavingTags(const TAGS& tags) const 
-	{
-		using namespace wibble::operators;
-		if (tags.empty())
-			return typename coll_traits<Self>::itemset_type();
-
-		typename TAGS::const_iterator i = tags.begin();
-		typename coll_traits<Self>::itemset_type res = self().getItemsHavingTag(*i);
-
-		for ( ; i != tags.end(); ++i)
-			res &= self().getItemsHavingTag(*i);
-
-		return res;
-	}
+	typename coll_traits<Self>::itemset_type getItemsHavingTags(const TAGS& tags) const;
 
 	/**
 	 * Get the set of all the items that have tags according to this collection
@@ -143,10 +121,7 @@
 	/**
 	 * Get the cardinality of tag `tag' (that is, the number of items who have it)
 	 */
-	int getCardinality(const typename coll_traits<Self>::tag_type& tag) const
-	{
-		return self().getItemsHavingTag(tag).size();
-	}
+	int getCardinality(const typename coll_traits<Self>::tag_type& tag) const;
 
 	/**
 	 * Get the set of all tags in this collection that appear in tagsets
@@ -162,11 +137,7 @@
 	 * \endcode
 	 */
 	template<typename TAGS>
-	typename coll_traits<Self>::tagset_type getCompanionTags(const TAGS& tags) const
-	{
-		using namespace wibble::operators;
-		return self().getTagsOfItems(self().getItemsHavingTags(tags)) - tags;
-	}
+	typename coll_traits<Self>::tagset_type getCompanionTags(const TAGS& tags) const;
 
 	/**
 	 * Get the related items at the given maximum distance
@@ -200,57 +171,20 @@
 	 * \endcode
 	 */
 	template<typename TAGS>
-	typename coll_traits<Self>::itemset_type getRelatedItems(const TAGS& tags, int maxdistance = 1) const
-	{
-		using namespace wibble::operators;
-
-		typename coll_traits<Self>::itemset_type packages;
-		typename coll_traits<Self>::itemset_type res;
-
-		// First get a list of packages that have a non-empty intersection with `tags'
-		for (typename TAGS::const_iterator i = tags.begin(); i != tags.end(); i++)
-			packages |= self().getItemsHavingTag(*i);
-
-		// Then keep only those within the given distance
-		for (typename coll_traits<Self>::itemset_type::const_iterator i = packages.begin(); i != packages.end(); i++)
-		{
-			int dist = utils::set_distance(tags, self().getTagsOfItem(*i));
-			if (dist >= 0 && dist <= maxdistance)
-				res |= *i;
-		}
-
-		return res;
-	}
+	typename coll_traits<Self>::itemset_type getRelatedItems(const TAGS& tags, int maxdistance = 1) const;
 
 	/**
 	 * Output all the contents of the collection to a Consumer
 	 */
 	template<typename OUT>
-	void output(OUT out) const
-	{
-		for (typename Self::const_iterator i = self().begin();
-				i != self().end(); ++i)
-		{
-			*out = make_pair(wibble::singleton(i->first), i->second);
-			++out;
-		}
-	}
+	void output(OUT out) const;
 
 	/**
 	 * Send to a consumer all the items which are tagged with at least the
 	 * given tags
 	 */
 	template<typename TAGS, typename OUT>
-	void outputHavingTags(const TAGS& tags, OUT out) const
-	{
-		typename coll_traits<Self>::itemset_type items = self().getItemsHavingTags(tags);
-		for (typename coll_traits<Self>::itemset_type::const_iterator i = items.begin();
-				i != items.end(); ++i)
-		{
-			*out = std::make_pair(*i, self().getTagsOfItem(*i));
-			++out;
-		}
-	}
+	void outputHavingTags(const TAGS& tags, OUT out) const;
 };
 
 

Modified: tagcoll/2.0/tagcoll/coll/fast.h
==============================================================================
--- tagcoll/2.0/tagcoll/coll/fast.h	(original)
+++ tagcoll/2.0/tagcoll/coll/fast.h	Thu May 11 13:38:34 2006
@@ -24,6 +24,8 @@
  */
 
 #include <tagcoll/coll/base.h>
+#include <wibble/operators.h>
+#include <set>
 #include <map>
 
 namespace tagcoll {

Modified: tagcoll/2.0/tagcoll/coll/fast.tcc
==============================================================================
--- tagcoll/2.0/tagcoll/coll/fast.tcc	(original)
+++ tagcoll/2.0/tagcoll/coll/fast.tcc	Thu May 11 13:38:34 2006
@@ -22,6 +22,7 @@
 #define TAGCOLL_COLL_FAST_TCC
 
 #include <tagcoll/coll/fast.h>
+#include <tagcoll/utils/set.h>
 #include <tagcoll/Patches.h>
 
 #include <wibble/operators.h>

Modified: tagcoll/2.0/tagcoll/coll/patched.tcc
==============================================================================
--- tagcoll/2.0/tagcoll/coll/patched.tcc	(original)
+++ tagcoll/2.0/tagcoll/coll/patched.tcc	Thu May 11 13:38:34 2006
@@ -22,6 +22,7 @@
 #define TAGCOLL_COLL_PATCHED_TCC
 
 #include <tagcoll/coll/patched.h>
+#include <tagcoll/utils/set.h>
 
 #include <wibble/operators.h>
 

Modified: tagcoll/2.0/tagcoll/coll/simple.h
==============================================================================
--- tagcoll/2.0/tagcoll/coll/simple.h	(original)
+++ tagcoll/2.0/tagcoll/coll/simple.h	Thu May 11 13:38:34 2006
@@ -28,6 +28,7 @@
 
 #include <tagcoll/coll/base.h>
 
+#include <wibble/operators.h>
 #include <map>
 
 namespace tagcoll {



More information about the Debtags-commits mailing list