[Debtags-commits] [svn] r944 - libtagcoll1/trunk/tagcoll
Enrico Zini
debtags-commits@lists.alioth.debian.org
Mon, 27 Jun 2005 02:21:35 +0000
Author: enrico
Date: Mon Jun 27 02:21:33 2005
New Revision: 944
Modified:
libtagcoll1/trunk/tagcoll/TagCollection.cc
libtagcoll1/trunk/tagcoll/TagCollection.h
Log:
Polished TagCollection a bit
Modified: libtagcoll1/trunk/tagcoll/TagCollection.cc
==============================================================================
--- libtagcoll1/trunk/tagcoll/TagCollection.cc (original)
+++ libtagcoll1/trunk/tagcoll/TagCollection.cc Mon Jun 27 02:21:33 2005
@@ -507,6 +507,16 @@
}
template<class ITEM, class TAG>
+int TagCollection<ITEM, TAG>::getCardinality(const TAG& tag) const throw ()
+{
+ typename TagContainer::const_iterator found = tags.find(tag);
+ if (found == tags.end())
+ return 0;
+ else
+ return found->second;
+}
+
+template<class ITEM, class TAG>
TAG TagCollection<ITEM, TAG>::findTagWithMaxCardinalityNotIn(const OpSet<TAG>& ntags, int* card) const throw ()
{
TAG candidate;
Modified: libtagcoll1/trunk/tagcoll/TagCollection.h
==============================================================================
--- libtagcoll1/trunk/tagcoll/TagCollection.h (original)
+++ libtagcoll1/trunk/tagcoll/TagCollection.h Mon Jun 27 02:21:33 2005
@@ -46,6 +46,9 @@
template<class ITEM, class TAG>
class TagCollection : public TaggedCollection<ITEM, TAG>
{
+public:
+ typedef std::map<OpSet<TAG>, OpSet<ITEM> > tagsets_t;
+
protected:
class TagContainer : public std::map<TAG, int>
{
@@ -58,7 +61,6 @@
TagContainer tags;
// Tag sets in this collection, with their item set
- typedef std::map<OpSet<TAG>, OpSet<ITEM> > tagsets_t;
tagsets_t tagsets;
// Items that have no tags in this collection
@@ -205,6 +207,11 @@
// contain the tags in `tags'
TagCollection<ITEM, TAG> getCollectionWithoutTagsetsHavingAnyOf(const OpSet<TAG>& tag) const throw ();
+ /**
+ * Get the cardinality of the given tag
+ */
+ int getCardinality(const TAG& tag) const throw ();
+
// Return the tag with maximum cardinality
TAG findTagWithMaxCardinalityNotIn(const OpSet<TAG>& tags, int* card = 0) const throw ();