Logo Search packages:      
Sourcecode: tagcoll version File versions  Download package

Tagcoll::ItemGrouper< ITEM, TAG > Class Template Reference

#include <ItemGrouper.h>

Inheritance diagram for Tagcoll::ItemGrouper< ITEM, TAG >:

Tagcoll::Collection< ITEM, TAG > Tagcoll::Consumer< ITEM, TAG >

List of all members.


Detailed Description

template<class ITEM, class TAG>
class Tagcoll::ItemGrouper< ITEM, TAG >

Collection grouping items having the same tagset.

The intended usage is mainly for compressing a stream of tags putting items together, for example to have a more compact output when serialising.

For most other collection operations, it's even more unefficient than InputMerger.

Examples:

 // Serialize the collection, giving the serializer a chance to group
 // together the items with the same tags
 void serializeCompact(const Collection<Item, Tag>& coll)
 {
    ItemGrouper<Item, Tag> grouper;
    coll.output(grouper);
    grouper.output(serializer);
 }

 // Serialize the reversed collection, associating to tags the items that
 // have them in the input.  It also won't output the same item twice, and
 // it gives the serializer a chance to group together the items with the
 // same tags
 void serializeReversed(const Collection<Item, Tag>& coll)
 {
    ItemGrouper<Item, Tag> grouper;
    coll.output(grouper);
    grouper.outputReversed(serializer);
 }

Definition at line 68 of file ItemGrouper.h.


Public Member Functions

virtual void applyChange (const PatchList< ITEM, TAG > &change)
void clear ()
void consume (const OpSet< ITEM > &items, const OpSet< TAG > &tags)
 Process a set of items identically tagged, with their tags.
void consume (const OpSet< ITEM > &items)
 Process a set of items, all with no tags.
void consume (const ITEM &item, const OpSet< TAG > &tags)
 Process a tagged item, with its tags.
void consume (const ITEM &item)
 Process an untagged item.
virtual OpSet< TAG > getAllTags () const
virtual int getCardinality (const TAG &tag) const
virtual OpSet< TAG > getCompanionTags (const OpSet< TAG > &tags) const
OpSet< ITEM > getItems (const OpSet< TAG > &tags) const
OpSet< ITEM > getItems (const TAG &tag) const
virtual OpSet< ITEM > getRelatedItems (const OpSet< TAG > &tags, int maxdistance=1) const
virtual OpSet< ITEM > getTaggedItems () const
OpSet< TAG > getTags (const OpSet< ITEM > &items) const
OpSet< TAG > getTags (const ITEM &item) const
virtual bool hasItem (const ITEM &item) const
virtual bool hasTag (const TAG &tag) const
virtual void output (Consumer< ITEM, TAG > &consumer) const
virtual void outputHavingTags (const OpSet< TAG > &tags, Consumer< ITEM, TAG > &consumer) const
void outputReversed (Consumer< TAG, ITEM > &consumer) const

Protected Types

typedef std::map< OpSet< TAG >
, OpSet< ITEM > > 
groups_t

Protected Member Functions

virtual void consumeItem (const ITEM &item, const OpSet< TAG > &tags)
 Process a tagged item, with its tags.
virtual void consumeItems (const OpSet< ITEM > &items, const OpSet< TAG > &tags)
 Process a set of items identically tagged, with their tags.
void consumeItemsUntagged (const OpSet< ITEM > &)
 Process a set of items, all with no tags.
void consumeItemUntagged (const ITEM &)
 Process an untagged item.
virtual OpSet< ITEM > getItemsHavingTag (const TAG &tag) const
virtual OpSet< ITEM > getItemsHavingTags (const OpSet< TAG > &tags) const
virtual OpSet< TAG > getTagsOfItem (const ITEM &item) const
virtual OpSet< TAG > getTagsOfItems (const OpSet< ITEM > &items) const

Protected Attributes

groups_t groups

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index