[Debtags-commits] [svn] r1561 - in tagcoll/trunk: . tagcoll tools
Enrico Zini
enrico at costa.debian.org
Sat Feb 11 12:24:58 UTC 2006
Author: enrico
Date: Sat Feb 11 12:24:57 2006
New Revision: 1561
Modified:
tagcoll/trunk/ (props changed)
tagcoll/trunk/tagcoll/IntDiskIndex.cc
tagcoll/trunk/tagcoll/IntDiskIndex.h
tagcoll/trunk/tools/Makefile.am
Log:
r7215 at viaza: enrico | 2006-02-10 14:01:58 +0100
Written indexer to use in tagcoll
Modified: tagcoll/trunk/tagcoll/IntDiskIndex.cc
==============================================================================
--- tagcoll/trunk/tagcoll/IntDiskIndex.cc (original)
+++ tagcoll/trunk/tagcoll/IntDiskIndex.cc Sat Feb 11 12:24:57 2006
@@ -24,97 +24,13 @@
using namespace Tagcoll;
-template<class ITEM, class TAG>
-IntDiskIndex<ITEM, TAG>::IntDiskIndex(
- const std::string& pkgidxfile,
- const std::string& tagidxfile,
- Converter<ITEM, int>& fromitem,
- Converter<TAG, int>& fromtag,
- Converter<int, ITEM>& toitem,
- Converter<int, TAG>& totag) :
- pkgidx(pkgidxfile), tagidx(tagidxfile),
- fromitem(fromitem), fromtag(fromtag),
- toitem(toitem), totag(totag) {}
-
-template<class ITEM, class TAG>
-bool IntDiskIndex<ITEM, TAG>::hasTag(const TAG& tag) const
-{
- return tagidx.size(fromtag(tag)) > 0;
-}
-
-template<class ITEM, class TAG>
-OpSet<ITEM> IntDiskIndex<ITEM, TAG>::getItemsHavingTag(const TAG& tag) const
-{
- OpSet<ITEM> res;
- int itag = fromtag(tag);
- for (unsigned int i = 0; i < tagidx.size(itag); i++)
- res += toitem(tagidx.data(itag)[i]);
- return res;
-}
-
-template<class ITEM, class TAG>
-OpSet<TAG> IntDiskIndex<ITEM, TAG>::getTagsOfItem(const ITEM& item) const
-{
- if (item != ITEM())
- {
- OpSet<TAG> res;
- int iitem = fromitem(item);
- for (unsigned int i = 0; i < pkgidx.size(iitem); i++)
- res += totag(pkgidx.data(iitem)[i]);
- return res;
- }
- else
- return OpSet<TAG>();
-}
-
-template<class ITEM, class TAG>
-int IntDiskIndex<ITEM, TAG>::getCardinality(const TAG& tag) const
-{
- return tagidx.size(fromtag(tag));
-}
-
-template<class ITEM, class TAG>
-OpSet<ITEM> IntDiskIndex<ITEM, TAG>::getTaggedItems() const
-{
- OpSet<ITEM> res;
- for (unsigned int i = 0; i < pkgidx.size(); i++)
- if (pkgidx.size(i) > 0)
- res += toitem(i);
- return res;
-}
-
-template<class ITEM, class TAG>
-OpSet<TAG> IntDiskIndex<ITEM, TAG>::getAllTags() const
-{
- OpSet<TAG> res;
- for (unsigned int i = 0; i < tagidx.size(); i++)
- res += totag(i);
- return res;
-}
-
-template<class ITEM, class TAG>
-void IntDiskIndex<ITEM, TAG>::output(Consumer<ITEM, TAG>& consumer) const
-{
- for (unsigned int i = 0; i < pkgidx.size(); i++)
- if (pkgidx.size(i) > 0)
- {
- OpSet<TAG> tags;
- for (unsigned int j = 0; j < pkgidx.size(i); j++)
- tags += totag(pkgidx.data(i)[j]);
- consumer.consume(toitem(i), tags);
- }
-}
-
template<class ITEM, class TAG>
IntDiskIndexer<ITEM, TAG>::IntDiskIndexer(
Converter<ITEM, int>& fromitem,
- Converter<TAG, int>& fromtag,
- Converter<int, ITEM>& toitem,
- Converter<int, TAG>& totag)
- : fromitem(fromitem), fromtag(fromtag),
- toitem(toitem), totag(totag) {}
+ Converter<TAG, int>& fromtag)
+ : fromitem(fromitem), fromtag(fromtag) {}
template<class ITEM, class TAG>
void IntDiskIndexer<ITEM, TAG>::consumeItem(const ITEM& item, const OpSet<TAG>& tags)
@@ -136,7 +52,6 @@
}
-
#ifndef INSTANTIATING_TEMPLATES
#include <string>
@@ -259,7 +174,7 @@
tagcoll_intdiskindex_shar()
: conv1(items), conv2(tags), conv3(items), conv4(tags)
{
- IntDiskIndexer<string, string> indexer(conv1, conv2, conv3, conv4);
+ IntDiskIndexer<string, string> indexer(conv1, conv2);
output_test_collection(indexer);
indexer.write(pkgfname, tagfname);
}
Modified: tagcoll/trunk/tagcoll/IntDiskIndex.h
==============================================================================
--- tagcoll/trunk/tagcoll/IntDiskIndex.h (original)
+++ tagcoll/trunk/tagcoll/IntDiskIndex.h Sat Feb 11 12:24:57 2006
@@ -54,8 +54,28 @@
mutable Converter<int, ITEM>& toitem;
mutable Converter<int, TAG>& totag;
- virtual OpSet<ITEM> getItemsHavingTag(const TAG& tag) const;
- virtual OpSet<TAG> getTagsOfItem(const ITEM& item) const;
+ virtual OpSet<ITEM> getItemsHavingTag(const TAG& tag) const
+ {
+ OpSet<ITEM> res;
+ int itag = fromtag(tag);
+ for (unsigned int i = 0; i < tagidx.size(itag); i++)
+ res += toitem(tagidx.data(itag)[i]);
+ return res;
+ }
+
+ virtual OpSet<TAG> getTagsOfItem(const ITEM& item) const
+ {
+ if (item != ITEM())
+ {
+ OpSet<TAG> res;
+ int iitem = fromitem(item);
+ for (unsigned int i = 0; i < pkgidx.size(iitem); i++)
+ res += totag(pkgidx.data(iitem)[i]);
+ return res;
+ }
+ else
+ return OpSet<TAG>();
+ }
public:
/**
@@ -81,17 +101,50 @@
Converter<ITEM, int>& fromitem,
Converter<TAG, int>& fromtag,
Converter<int, ITEM>& toitem,
- Converter<int, TAG>& totag);
+ Converter<int, TAG>& totag)
+ : pkgidx(pkgidxfile), tagidx(tagidxfile),
+ fromitem(fromitem), fromtag(fromtag),
+ toitem(toitem), totag(totag) {}
virtual ~IntDiskIndex() {}
- virtual bool hasTag(const TAG& tag) const;
-
- virtual OpSet<ITEM> getTaggedItems() const;
- virtual OpSet<TAG> getAllTags() const;
-
- virtual int getCardinality(const TAG& tag) const;
-
- virtual void output(Consumer<ITEM, TAG>& consumer) const;
+ virtual bool hasTag(const TAG& tag) const
+ {
+ return tagidx.size(fromtag(tag)) > 0;
+ }
+
+ virtual OpSet<ITEM> getTaggedItems() const
+ {
+ OpSet<ITEM> res;
+ for (unsigned int i = 0; i < pkgidx.size(); i++)
+ if (pkgidx.size(i) > 0)
+ res += toitem(i);
+ return res;
+ }
+
+ virtual OpSet<TAG> getAllTags() const
+ {
+ OpSet<TAG> res;
+ for (unsigned int i = 0; i < tagidx.size(); i++)
+ res += totag(i);
+ return res;
+ }
+
+ virtual int getCardinality(const TAG& tag) const
+ {
+ return tagidx.size(fromtag(tag));
+ }
+
+ virtual void output(Consumer<ITEM, TAG>& consumer) const
+ {
+ for (unsigned int i = 0; i < pkgidx.size(); i++)
+ if (pkgidx.size(i) > 0)
+ {
+ OpSet<TAG> tags;
+ for (unsigned int j = 0; j < pkgidx.size(i); j++)
+ tags += totag(pkgidx.data(i)[j]);
+ consumer.consume(toitem(i), tags);
+ }
+ }
};
template<class ITEM, class TAG>
@@ -102,8 +155,6 @@
IntIndexer tagidx;
mutable Converter<ITEM, int>& fromitem;
mutable Converter<TAG, int>& fromtag;
- mutable Converter<int, ITEM>& toitem;
- mutable Converter<int, TAG>& totag;
virtual void consumeItemUntagged(const ITEM& item) {}
virtual void consumeItem(const ITEM& item, const OpSet<TAG>& tags);
@@ -111,9 +162,7 @@
public:
IntDiskIndexer(
Converter<ITEM, int>& fromitem,
- Converter<TAG, int>& fromtag,
- Converter<int, ITEM>& toitem,
- Converter<int, TAG>& totag);
+ Converter<TAG, int>& fromtag);
virtual ~IntDiskIndexer() {}
void write(const std::string& pkgidx, const std::string& tagidx);
Modified: tagcoll/trunk/tools/Makefile.am
==============================================================================
--- tagcoll/trunk/tools/Makefile.am (original)
+++ tagcoll/trunk/tools/Makefile.am Sat Feb 11 12:24:57 2006
@@ -2,7 +2,7 @@
bin_PROGRAMS = tagcoll taggrep
-tagcoll_SOURCES = tagcoll.cc CommandlineParser.cc
+tagcoll_SOURCES = Index.cc tagcoll.cc CommandlineParser.cc
tagcoll_LDADD = ../tagcoll/libtagcoll.la ../tagcoll/tagexpr/libtagexpr.la
#$(LIBTAGCOLL1_LIBS)
@@ -13,4 +13,4 @@
INCLUDES = -I$(top_srcdir)
#$(LIBTAGCOLL1_CFLAGS)
-EXTRA_DIST = CommandlineParser.h
+EXTRA_DIST = CommandlineParser.h Index.h
More information about the Debtags-commits
mailing list