[Debtags-commits] [svn] r1771 - in tagcoll/2.0: . tagcoll/coll
tagcoll/stream
Enrico Zini
enrico at costa.debian.org
Thu May 11 13:41:45 UTC 2006
Author: enrico
Date: Thu May 11 13:41:44 2006
New Revision: 1771
Modified:
tagcoll/2.0/ (props changed)
tagcoll/2.0/tagcoll/coll/fast.h
tagcoll/2.0/tagcoll/coll/fast.tcc
tagcoll/2.0/tagcoll/coll/simple.h
tagcoll/2.0/tagcoll/coll/simple.tcc
tagcoll/2.0/tagcoll/stream/filters.cc
Log:
r2721 at viaza: enrico | 2006-05-11 08:14:17 -0500
Moved function bodies from the .h to the .tcc
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:41:44 2006
@@ -24,7 +24,6 @@
*/
#include <tagcoll/coll/base.h>
-#include <wibble/operators.h>
#include <set>
#include <map>
@@ -73,33 +72,7 @@
iterator end() { return items.end(); }
template<typename ITEMS, typename TAGS>
- void insert(const ITEMS& items, const TAGS& tags)
- {
- using namespace wibble::operators;
-
- if (tags.empty())
- return;
-
- for (typename ITEMS::const_iterator i = items.begin();
- i != items.end(); ++i)
- {
- typename std::map< ITEM, std::set<TAG> >::iterator iter = this->items.find(*i);
- if (iter == this->items.end())
- this->items.insert(std::make_pair(*i, std::set<TAG>() | tags));
- else
- iter->second |= tags;
- }
-
- for (typename TAGS::const_iterator i = tags.begin();
- i != tags.end(); ++i)
- {
- typename std::map< TAG, std::set<ITEM> >::iterator iter = this->tags.find(*i);
- if (iter == this->tags.end())
- this->tags.insert(std::make_pair(*i, std::set<ITEM>() | items));
- else
- iter->second |= items;
- }
- }
+ void insert(const ITEMS& items, const TAGS& tags);
std::set<TAG> getTagsOfItem(const ITEM& item) const;
std::set<ITEM> getItemsHavingTag(const TAG& tag) const;
@@ -124,56 +97,14 @@
std::set<TAG> getTagsImplying(const TAG& tag) const;
// Return the items which have the exact tagset 'tags'
- std::set<ITEM> getItemsExactMatch(const std::set<TAG>& tags) const
- {
- std::set<ITEM> res = getItemsHavingTags(tags);
- typename std::set<ITEM>::iterator i = res.begin();
- while (i != res.end())
- {
- typename std::map<ITEM, std::set<TAG> >::const_iterator t = items.find(*i);
- if (t != items.end() && t->second != tags)
- {
- typename std::set<ITEM>::iterator j = i;
- ++i;
- res.erase(j);
- } else
- ++i;
- }
- return res;
- }
-
- TAG findTagWithMaxCardinality(size_t& card) const
- {
- card = 0;
- TAG res;
- for (typename std::map<TAG, std::set<ITEM> >::const_iterator i = tags.begin();
- i != tags.end(); ++i)
- if (i->second.size() > card)
- {
- card = i->second.size();
- res = i->first;
- }
- return res;
- }
+ std::set<ITEM> getItemsExactMatch(const std::set<TAG>& tags) const;
+
+ TAG findTagWithMaxCardinality(size_t& card) const;
Fast<ITEM, TAG> getChildCollection(const TAG& tag) const;
void removeTag(const TAG& tag);
-
- void removeTagsWithCardinalityLessThan(size_t card)
- {
- typename std::map<TAG, std::set<ITEM> >::const_iterator i = tags.begin();
- while (i != tags.end())
- {
- if (i->second.size() < card)
- {
- typename std::map<TAG, std::set<ITEM> >::const_iterator j = i;
- ++i;
- removeTag(j->first);
- } else
- ++i;
- }
- }
+ void removeTagsWithCardinalityLessThan(size_t card);
};
}
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:41:44 2006
@@ -33,6 +33,35 @@
namespace tagcoll {
namespace coll {
+template<class ITEM, class TAG> template<typename ITEMS, typename TAGS>
+void Fast<ITEM, TAG>::insert(const ITEMS& items, const TAGS& tags)
+{
+ using namespace wibble::operators;
+
+ if (tags.empty())
+ return;
+
+ for (typename ITEMS::const_iterator i = items.begin();
+ i != items.end(); ++i)
+ {
+ typename std::map< ITEM, std::set<TAG> >::iterator iter = this->items.find(*i);
+ if (iter == this->items.end())
+ this->items.insert(std::make_pair(*i, std::set<TAG>() | tags));
+ else
+ iter->second |= tags;
+ }
+
+ for (typename TAGS::const_iterator i = tags.begin();
+ i != tags.end(); ++i)
+ {
+ typename std::map< TAG, std::set<ITEM> >::iterator iter = this->tags.find(*i);
+ if (iter == this->tags.end())
+ this->tags.insert(std::make_pair(*i, std::set<ITEM>() | items));
+ else
+ iter->second |= items;
+ }
+}
+
template<class ITEM, class TAG>
std::set<ITEM> Fast<ITEM, TAG>::getItemsHavingTag(const TAG& tag) const
{
@@ -138,6 +167,40 @@
#endif
return res - tag;
}
+
+template<class ITEM, class TAG>
+std::set<ITEM> Fast<ITEM, TAG>::getItemsExactMatch(const std::set<TAG>& tags) const
+{
+ std::set<ITEM> res = getItemsHavingTags(tags);
+ typename std::set<ITEM>::iterator i = res.begin();
+ while (i != res.end())
+ {
+ typename std::map<ITEM, std::set<TAG> >::const_iterator t = items.find(*i);
+ if (t != items.end() && t->second != tags)
+ {
+ typename std::set<ITEM>::iterator j = i;
+ ++i;
+ res.erase(j);
+ } else
+ ++i;
+ }
+ return res;
+}
+
+template<class ITEM, class TAG>
+TAG Fast<ITEM, TAG>::findTagWithMaxCardinality(size_t& card) const
+{
+ card = 0;
+ TAG res;
+ for (typename std::map<TAG, std::set<ITEM> >::const_iterator i = tags.begin();
+ i != tags.end(); ++i)
+ if (i->second.size() > card)
+ {
+ card = i->second.size();
+ res = i->first;
+ }
+ return res;
+}
template<class ITEM, class TAG>
void Fast<ITEM, TAG>::removeTag(const TAG& tag)
@@ -171,6 +234,22 @@
return res;
}
+template<class ITEM, class TAG>
+void Fast<ITEM, TAG>::removeTagsWithCardinalityLessThan(size_t card)
+{
+ typename std::map<TAG, std::set<ITEM> >::const_iterator i = tags.begin();
+ while (i != tags.end())
+ {
+ if (i->second.size() < card)
+ {
+ typename std::map<TAG, std::set<ITEM> >::const_iterator j = i;
+ ++i;
+ removeTag(j->first);
+ } else
+ ++i;
+ }
+}
+
#if 0
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:41:44 2006
@@ -27,8 +27,7 @@
*/
#include <tagcoll/coll/base.h>
-
-#include <wibble/operators.h>
+#include <set>
#include <map>
namespace tagcoll {
@@ -83,22 +82,7 @@
bool empty() const { return coll.empty(); }
template<typename ITEMS, typename TAGS>
- void insert(const ITEMS& items, const TAGS& tags)
- {
- using namespace wibble::operators;
-
- if (tags.empty())
- return;
- for (typename ITEMS::const_iterator i = items.begin();
- i != items.end(); ++i)
- {
- typename std::map< ITEM, std::set<TAG> >::iterator iter = coll.find(*i);
- if (iter == coll.end())
- coll.insert(std::make_pair(*i, std::set<TAG>() | tags));
- else
- iter->second |= tags;
- }
- }
+ void insert(const ITEMS& items, const TAGS& tags);
bool hasItem(const ITEM& item) const { return coll.find(item) != coll.end(); }
@@ -123,14 +107,7 @@
void applyChange(const PatchList<ITEM, TAG>& change);
- std::set<ITEM> getTaggedItems() const
- {
- std::set<ITEM> res;
- for (typename std::map< ITEM, std::set<TAG> >::const_iterator i = coll.begin();
- i != coll.end(); i++)
- res.insert(i->first);
- return res;
- }
+ std::set<ITEM> getTaggedItems() const;
std::set<TAG> getAllTags() const;
Modified: tagcoll/2.0/tagcoll/coll/simple.tcc
==============================================================================
--- tagcoll/2.0/tagcoll/coll/simple.tcc (original)
+++ tagcoll/2.0/tagcoll/coll/simple.tcc Thu May 11 13:41:44 2006
@@ -33,17 +33,24 @@
namespace tagcoll {
namespace coll {
-#if 0
-template<class T, class Tag>
-void Simple<T, Tag>::consumeItem(const T& item, const std::set<Tag>& tags)
+
+template<class ITEM, class TAG> template<typename ITEMS, typename TAGS>
+void Simple<ITEM, TAG>::insert(const ITEMS& items, const TAGS& tags)
{
- typename map< T, std::set<Tag> >::iterator i = coll.find(item);
- if (i == coll.end())
- coll.insert(make_pair(item, tags));
- else
- i->second |= tags;
+ using namespace wibble::operators;
+
+ if (tags.empty())
+ return;
+ for (typename ITEMS::const_iterator i = items.begin();
+ i != items.end(); ++i)
+ {
+ typename std::map< ITEM, std::set<TAG> >::iterator iter = coll.find(*i);
+ if (iter == coll.end())
+ coll.insert(std::make_pair(*i, std::set<TAG>() | tags));
+ else
+ iter->second |= tags;
+ }
}
-#endif
template<class ITEM, class TAG>
std::set<TAG> Simple<ITEM, TAG>::getTagsOfItem(const ITEM& item) const
@@ -122,6 +129,16 @@
}
}
+template<typename ITEM, typename TAG>
+std::set<ITEM> Simple<ITEM, TAG>::getTaggedItems() const
+{
+ std::set<ITEM> res;
+ for (typename std::map< ITEM, std::set<TAG> >::const_iterator i = coll.begin();
+ i != coll.end(); i++)
+ res.insert(i->first);
+ return res;
+}
+
template<class T, class Tag>
std::set<Tag> Simple<T, Tag>::getAllTags() const
{
Modified: tagcoll/2.0/tagcoll/stream/filters.cc
==============================================================================
--- tagcoll/2.0/tagcoll/stream/filters.cc (original)
+++ tagcoll/2.0/tagcoll/stream/filters.cc Thu May 11 13:41:44 2006
@@ -194,6 +194,7 @@
#include <tagcoll/TextFormat.tcc>
#include <tagcoll/stream/filters.tcc>
+#include <tagcoll/coll/simple.tcc>
#endif
// vim:set ts=4 sw=4:
More information about the Debtags-commits
mailing list