[Debtags-commits] [svn] r891 - libtagcoll1/trunk/tagcoll

Enrico Zini debtags-commits@lists.alioth.debian.org
Fri, 17 Jun 2005 23:00:28 +0000


Author: enrico
Date: Fri Jun 17 23:00:26 2005
New Revision: 891

Modified:
   libtagcoll1/trunk/tagcoll/DiskIndex.cc
   libtagcoll1/trunk/tagcoll/DiskIndex.h
   libtagcoll1/trunk/tagcoll/InputMerger.cc
   libtagcoll1/trunk/tagcoll/InputMerger.h
   libtagcoll1/trunk/tagcoll/TDBDiskIndex.h
   libtagcoll1/trunk/tagcoll/TagCollection.cc
   libtagcoll1/trunk/tagcoll/TagCollection.h
   libtagcoll1/trunk/tagcoll/TaggedCollection.h
Log:
Added outputHavingTags to TaggedCollection

Modified: libtagcoll1/trunk/tagcoll/DiskIndex.cc
==============================================================================
--- libtagcoll1/trunk/tagcoll/DiskIndex.cc	(original)
+++ libtagcoll1/trunk/tagcoll/DiskIndex.cc	Fri Jun 17 23:00:26 2005
@@ -65,6 +65,16 @@
 }
 
 template<class ITEM, class TAG>
+void DiskIndex<ITEM, TAG>::outputHavingTags(const OpSet<TAG>& ts, TagcollConsumer<ITEM, TAG>& consumer) const
+{
+	OpSet<ITEM> items = getItems(ts);
+	for (typename OpSet<ITEM>::const_iterator i = items.begin();
+			i != items.end(); i++)
+		consumer.consume(*i, getTags(*i));
+}
+
+
+template<class ITEM, class TAG>
 OpSet<ITEM> DiskIndex<ITEM, TAG>::getRelatedItems(const ITEM& item, int maxdistance) const
 {
 	return getRelatedItems(getTags(item), maxdistance);

Modified: libtagcoll1/trunk/tagcoll/DiskIndex.h
==============================================================================
--- libtagcoll1/trunk/tagcoll/DiskIndex.h	(original)
+++ libtagcoll1/trunk/tagcoll/DiskIndex.h	Fri Jun 17 23:00:26 2005
@@ -102,6 +102,9 @@
 	 */
 	virtual void output(TagcollConsumer<ITEM, TAG>& consumer) const = 0;
 
+	virtual void outputHavingTags(const OpSet<TAG>& ts, TagcollConsumer<ITEM, TAG>& consumer) const;
+
+
 	/**
 	 * Get the set of all tags in this collection that appear in tagsets
 	 * containing `ts'

Modified: libtagcoll1/trunk/tagcoll/InputMerger.cc
==============================================================================
--- libtagcoll1/trunk/tagcoll/InputMerger.cc	(original)
+++ libtagcoll1/trunk/tagcoll/InputMerger.cc	Fri Jun 17 23:00:26 2005
@@ -105,6 +105,17 @@
 			consumer.consume(i->first, i->second);
 }
 
+template<class ITEM, class TAG>
+void InputMerger<ITEM, TAG>::outputHavingTags(const OpSet<TAG>& ts, TagcollConsumer<ITEM, TAG>& consumer) const
+{
+	for (typename map< ITEM, OpSet<TAG> >::const_iterator i = coll.begin();
+			i != coll.end(); i++)
+		if (i->second.contains(ts))
+			consumer.consume(i->first, i->second);
+}
+
+	
+
 
 template<class T, class Tag>
 void InputMerger<T, Tag>::applyChange(const PatchList<T, Tag>& change) throw ()

Modified: libtagcoll1/trunk/tagcoll/InputMerger.h
==============================================================================
--- libtagcoll1/trunk/tagcoll/InputMerger.h	(original)
+++ libtagcoll1/trunk/tagcoll/InputMerger.h	Fri Jun 17 23:00:26 2005
@@ -93,6 +93,9 @@
 	 */
 	void output(TagcollConsumer<ITEM, TAG>& consumer) const throw ();
 
+	void outputHavingTags(const OpSet<TAG>& ts, TagcollConsumer<ITEM, TAG>& consumer) const;
+
+
 	/**
 	 * Apply a Change to the collection
 	 */

Modified: libtagcoll1/trunk/tagcoll/TDBDiskIndex.h
==============================================================================
--- libtagcoll1/trunk/tagcoll/TDBDiskIndex.h	(original)
+++ libtagcoll1/trunk/tagcoll/TDBDiskIndex.h	Fri Jun 17 23:00:26 2005
@@ -111,6 +111,7 @@
 	 */
 	virtual void output(TagcollConsumer<ITEM, TAG>& consumer) const throw (SystemException);
 
+
 	/**
 	 * Apply a Change to the collection; return a reverse change that can be
 	 * reused to undo the operation

Modified: libtagcoll1/trunk/tagcoll/TagCollection.cc
==============================================================================
--- libtagcoll1/trunk/tagcoll/TagCollection.cc	(original)
+++ libtagcoll1/trunk/tagcoll/TagCollection.cc	Fri Jun 17 23:00:26 2005
@@ -685,4 +685,14 @@
 		cons.consume(i->second, i->first);
 }
 
+template<class ITEM, class TAG>
+void TagCollection<ITEM, TAG>::outputHavingTags(const OpSet<TAG>& ts, TagcollConsumer<ITEM, TAG>& consumer) const
+{
+	for (typename tagsets_t::const_iterator t = tagsets.begin();
+			t != tagsets.end(); t++)
+		if (t->first.contains(ts))
+			consumer.consume(t->second, t->first);
+}
+
+
 // vim:set ts=4 sw=4:

Modified: libtagcoll1/trunk/tagcoll/TagCollection.h
==============================================================================
--- libtagcoll1/trunk/tagcoll/TagCollection.h	(original)
+++ libtagcoll1/trunk/tagcoll/TagCollection.h	Fri Jun 17 23:00:26 2005
@@ -222,6 +222,8 @@
 	
 	// Output the contents of the collection to a TagcollConsumer
 	void output(TagcollConsumer<ITEM, TAG>& cons) const throw ();
+
+	void outputHavingTags(const OpSet<TAG>& ts, TagcollConsumer<ITEM, TAG>& consumer) const;
 };
 
 };

Modified: libtagcoll1/trunk/tagcoll/TaggedCollection.h
==============================================================================
--- libtagcoll1/trunk/tagcoll/TaggedCollection.h	(original)
+++ libtagcoll1/trunk/tagcoll/TaggedCollection.h	Fri Jun 17 23:00:26 2005
@@ -94,6 +94,12 @@
 	 * Send the data to a consumer
 	 */
 	virtual void output(TagcollConsumer<ITEM, TAG>& consumer) const = 0;
+
+	/**
+	 * Send to a consumer all the items which are tagged with at least the
+	 * given tags
+	 */
+	virtual void outputHavingTags(const OpSet<TAG>& ts, TagcollConsumer<ITEM, TAG>& consumer) const = 0;
 };
 
 };