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

Enrico Zini enrico at costa.debian.org
Tue May 9 00:08:15 UTC 2006


Author: enrico
Date: Tue May  9 00:08:15 2006
New Revision: 1712

Modified:
   tagcoll/2.0/   (props changed)
   tagcoll/2.0/tagcoll/sink.h
Log:
 r2599 at viaza:  enrico | 2006-05-07 11:13:11 -0500
 Implemented a counting sink


Modified: tagcoll/2.0/tagcoll/sink.h
==============================================================================
--- tagcoll/2.0/tagcoll/sink.h	(original)
+++ tagcoll/2.0/tagcoll/sink.h	Tue May  9 00:08:15 2006
@@ -38,6 +38,39 @@
 	Sink& operator=(const Data&) const { return *this; }
 };
 
+Sink sink()
+{
+	return Sink();
+}
+
+
+/**
+ * Consumer that discards its input
+ */
+class CountingSink : public wibble::mixin::OutputIterator<CountingSink>
+{
+	int& count;
+public:
+	ContingSink(int& count) : count(count) {}
+
+	// TODO: see if there's a way of implementing the count using size() when
+	// the method actually exists
+	template<typename ITEMS, typename TAGS>
+	CountingSink& operator=(const std::pair<ITEMS, TAGS>& data)
+	{
+		for (typename ITEMS::const_iterator i = data.first.begin();
+				i != data.first.end(); ++i)
+			++count;
+		return *this;
+	}
+};
+
+CountingSink countingSink(int& count)
+{
+	return CountingSink(count);
+}
+
+
 };
 
 // vim:set ts=4 sw=4:



More information about the Debtags-commits mailing list