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

In-memory collection keeping a fast-access track of tag cardinalities. More...

#include <CardinalityStore.h>

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

Inheritance graph
[legend]
Collaboration diagram for Tagcoll::CardinalityStore< ITEM, TAG >:

Collaboration graph
[legend]
List of all members.
typedef tagsets_t::const_iterator const_iterator
 Iterators support.
typedef tagsets_t::iterator iterator
 Iterators support.
iterator begin ()
 Iterators support.
iterator end ()
 Iterators support.
const_iterator begin () const
 Iterators support.
const_iterator end () const
 Iterators support.

Public Types

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

Public Member Functions

 CardinalityStore ()
virtual ~CardinalityStore ()
int itemCount () const
 Get the total number of items in this collection.
int tagCount () const
 Get the number of different tags in this collection.
int tagsetCount () const
 Get the number of different tag sets in this collection.
OpSet< ITEM > getItemsExactMatch (const OpSet< TAG > &ts) const
 Get the set of items with exactly the given tagset.
bool hasItem (const ITEM &item) const
bool hasTag (const TAG &tag) const
 Check if the collection contains a tag.
OpSet< TAG > getAllTags () const
 Get the set of all the tags in this collection.
OpSet< ITEM > getTaggedItems () const
 Get the set of all the items that have tags according to this collection.
OpSet< TAG > getCompanionTags (const OpSet< TAG > &ts) const
 Get the set of all tags in this collection that appear in tagsets containing `tags'.
OpSet< ITEM > getCompanionItems (const OpSet< TAG > &ts) const
 Get the set of all items in this collection whose tagsets contain `ts'.
std::map< ITEM, OpSet< TAG > > getCompanionItemsAndTagsets (const OpSet< TAG > &ts) const
 Get the set of all items in this collection whose tagsets contain `ts'.
OpSet< ITEM > getRelatedItems (const OpSet< TAG > &ts, int maxdistance=1) const
 Get the related items at the given maximum distance.
std::list< OpSet< TAG > > getRelatedTagsets (const OpSet< TAG > &ts, int maxdistance=1) const
 Get the list of tagsets related to the given one, with distance > 0 and <= maxdistance.
void applyChange (const PatchList< ITEM, TAG > &change)
 Apply a patch to the collection.
CardinalityStore< ITEM, TAG > getChildCollection (const TAG &tag) const
 Return a tagged collection with all tagsets of this one that contain the tag `tag', but with the tag removed.
CardinalityStore< ITEM, TAG > getCollectionWithoutTags (const OpSet< TAG > &tag) const
 Return a tagged collection with all tagsets of this one that are nonempty when stripped by the tag `tag' and all tags that imply it.
CardinalityStore< ITEM, TAG > getCollectionWithoutTagsetsHaving (const TAG &tag) const
 Return the tagged collection with all tagsets of this one that do not contain the tag `tag'.
CardinalityStore< ITEM, TAG > getCollectionWithoutTagsetsHavingAnyOf (const OpSet< TAG > &tag) const
 Return the tagged collection with all tagsets of this one that do not contain the tags in `tags'.
OpSet< TAG > getImpliedBy (const TAG &tag) const
 Return the list of tags that the given tag implies.
int getCardinality (const TAG &tag) const
 Get the cardinality of tag `tag' (that is, the number of items who have it).
TAG findTagWithMaxCardinalityNotIn (const OpSet< TAG > &tags, int *card=0) const
void mergeEquivalentTags ()
void removeTagsWithCardinalityLessThan (int card)
void output (Consumer< ITEM, TAG > &cons) const
 Output all the contents of the collection to a Consumer.
void outputHavingTags (const OpSet< TAG > &ts, Consumer< ITEM, TAG > &consumer) const
 Send to a consumer all the items which are tagged with at least the given tags.

Protected Member Functions

OpSet< TAG > getImplyingOneOf (const OpSet< TAG > &tags) const
 Get the list of tags that imply one of the tags in `tags'.
void consumeItem (const ITEM &item, const OpSet< TAG > &tagset)
 Process a tagged item, with its tags.
void consumeItems (const OpSet< ITEM > &items, const OpSet< TAG > &tagset)
 Process a set of items identically tagged, with their tags.
virtual OpSet< ITEM > getItemsHavingTag (const TAG &tag) const
 Get the items which are tagged with at least the tag `tag'.
virtual OpSet< ITEM > getItemsHavingTags (const OpSet< TAG > &tags) const
 Get the items which are tagged with at least the tags `tags'.
virtual OpSet< TAG > getTagsOfItem (const ITEM &item) const
 Get the tags attached to an item.
virtual OpSet< TAG > getTagsOfItems (const OpSet< ITEM > &items) const
 Get all the tags attached to the items in a set.

Protected Attributes

TagContainer tags
tagsets_t tagsets

Classes

class  TagContainer

Detailed Description

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

In-memory collection keeping a fast-access track of tag cardinalities.

This in-memory collection has different computational-complexity behaviour from InputMerger, TDBIndexer or TDBDiskIndex, and can be more or less suited to be used as a collection than the other alternatives, depending on the computational needs of the caller.


Member Typedef Documentation

template<class ITEM, class TAG>
typedef std::map<OpSet<TAG>, OpSet<ITEM> > Tagcoll::CardinalityStore< ITEM, TAG >::tagsets_t

Reimplemented in Tagcoll::Normalizer< ITEM, TAG >, and Tagcoll::Graph< ITEM, TAG >.

template<class ITEM, class TAG>
typedef tagsets_t::const_iterator Tagcoll::CardinalityStore< ITEM, TAG >::const_iterator

Iterators support.

template<class ITEM, class TAG>
typedef tagsets_t::iterator Tagcoll::CardinalityStore< ITEM, TAG >::iterator

Iterators support.


Constructor & Destructor Documentation

template<class ITEM, class TAG>
Tagcoll::CardinalityStore< ITEM, TAG >::CardinalityStore (  )  [inline]

template<class ITEM, class TAG>
virtual Tagcoll::CardinalityStore< ITEM, TAG >::~CardinalityStore (  )  [inline, virtual]


Member Function Documentation

template<class ITEM, class TAG>
OpSet< TAG > CardinalityStore::getImplyingOneOf ( const OpSet< TAG > &  tags  )  const [protected]

Get the list of tags that imply one of the tags in `tags'.

template<class ITEM, class TAG>
void CardinalityStore::consumeItem ( const ITEM &  item,
const OpSet< TAG > &  tagset 
) [protected, virtual]

Process a tagged item, with its tags.

Implements Tagcoll::Consumer< ITEM, TAG >.

template<class ITEM, class TAG>
void CardinalityStore::consumeItems ( const OpSet< ITEM > &  items,
const OpSet< TAG > &  tagset 
) [protected, virtual]

Process a set of items identically tagged, with their tags.

Reimplemented from Tagcoll::Consumer< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< ITEM > CardinalityStore::getItemsHavingTag ( const TAG &  tag  )  const [protected, virtual]

Get the items which are tagged with at least the tag `tag'.

Returns:
The items found, or an empty set if no items have that tag

Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< ITEM > CardinalityStore::getItemsHavingTags ( const OpSet< TAG > &  tags  )  const [protected, virtual]

Get the items which are tagged with at least the tags `tags'.

Returns:
The items found, or an empty set if no items have that tag

Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< TAG > CardinalityStore::getTagsOfItem ( const ITEM &  item  )  const [protected, virtual]

Get the tags attached to an item.

Parameters:
item The item to query
Returns:
The set of tags, or an empty set if the item has no tags or it does not exist.

Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< TAG > CardinalityStore::getTagsOfItems ( const OpSet< ITEM > &  items  )  const [protected, virtual]

Get all the tags attached to the items in a set.

Parameters:
items The items to query
Returns:
The set of tags, or an empty set if the items have no tags or do not exist.

Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
iterator Tagcoll::CardinalityStore< ITEM, TAG >::begin (  )  [inline]

Iterators support.

template<class ITEM, class TAG>
iterator Tagcoll::CardinalityStore< ITEM, TAG >::end (  )  [inline]

Iterators support.

template<class ITEM, class TAG>
const_iterator Tagcoll::CardinalityStore< ITEM, TAG >::begin (  )  const [inline]

Iterators support.

template<class ITEM, class TAG>
const_iterator Tagcoll::CardinalityStore< ITEM, TAG >::end (  )  const [inline]

Iterators support.

template<class ITEM, class TAG>
int CardinalityStore::itemCount (  )  const

Get the total number of items in this collection.

template<class ITEM, class TAG>
int Tagcoll::CardinalityStore< ITEM, TAG >::tagCount (  )  const [inline]

Get the number of different tags in this collection.

template<class ITEM, class TAG>
int Tagcoll::CardinalityStore< ITEM, TAG >::tagsetCount (  )  const [inline]

Get the number of different tag sets in this collection.

template<class ITEM, class TAG>
OpSet< ITEM > CardinalityStore::getItemsExactMatch ( const OpSet< TAG > &  ts  )  const

Get the set of items with exactly the given tagset.

template<class ITEM, class TAG>
bool CardinalityStore::hasItem ( const ITEM &  item  )  const

template<class ITEM, class TAG>
bool Tagcoll::CardinalityStore< ITEM, TAG >::hasTag ( const TAG &  tag  )  const [inline, virtual]

Check if the collection contains a tag.

Parameters:
tag The tag to look for
Returns:
true if the collection contains tag, false otherwise

Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< TAG > CardinalityStore::getAllTags (  )  const [virtual]

Get the set of all the tags in this collection.

Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< ITEM > CardinalityStore::getTaggedItems (  )  const [virtual]

Get the set of all the items that have tags according to this collection.

Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< TAG > CardinalityStore::getCompanionTags ( const OpSet< TAG > &  ts  )  const [virtual]

Get the set of all tags in this collection that appear in tagsets containing `tags'.

Example:

 void refineSelection(const OpSet<Tag>& selection)
 {
    OpSet<Tag> extraTags = collection.getCompanionTags(selection);
    tagMenu.setAvailableOptions(extraTags);
 }

Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
OpSet< ITEM > CardinalityStore::getCompanionItems ( const OpSet< TAG > &  ts  )  const

Get the set of all items in this collection whose tagsets contain `ts'.

template<class ITEM, class TAG>
map< ITEM, OpSet< TAG > > CardinalityStore::getCompanionItemsAndTagsets ( const OpSet< TAG > &  ts  )  const

Get the set of all items in this collection whose tagsets contain `ts'.

template<class ITEM, class TAG>
OpSet< ITEM > CardinalityStore::getRelatedItems ( const OpSet< TAG > &  ts,
int  maxdistance = 1 
) const [virtual]

Get the related items at the given maximum distance.

Examples:

 // Get the items related to a given one, at the given distance
 OpSet<Item> getRelated(const Item& item, int distance)
 {
    OpSet<Item> res = collection.getRelatedItems(collection.getTags(item), distance);
    return res - item;
 }

 // Get the items related to the given ones, at the given distance
 OpSet<Item> getRelated(const OpSet<Item>& items, int distance)
 {
    OpSet<Item> res = collection.getRelatedItems(collection.getTags(items), distance);
    return res - items;
 }

 // Get the related items, increasing the distance until it finds at
 // least 'minimum' items
 OpSet<Item> getRelated(const Item& item, int minimum)
 {
    OpSet<Tag> tags = collection.getTags(item);
    OpSet<Item> res;
    for (int i = 0; i < tags.size() && res.size() < minimum; i++)
         res += collection.getRelatedItems(tags, i);
      return res - item;
 }

Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
list< OpSet< TAG > > CardinalityStore::getRelatedTagsets ( const OpSet< TAG > &  ts,
int  maxdistance = 1 
) const

Get the list of tagsets related to the given one, with distance > 0 and <= maxdistance.

template<class ITEM, class TAG>
void CardinalityStore::applyChange ( const PatchList< ITEM, TAG > &  change  )  [virtual]

Apply a patch to the collection.

Example:

 void perform(const PatchList<ITEM, TAG>& change)
 {
    collection.applyChange(change);
    undo.push_back(change.getReverse());
 }

Implements Tagcoll::Collection< ITEM, TAG >.

template<class ITEM, class TAG>
CardinalityStore< ITEM, TAG > CardinalityStore::getChildCollection ( const TAG &  tag  )  const

Return a tagged collection with all tagsets of this one that contain the tag `tag', but with the tag removed.

template<class ITEM, class TAG>
CardinalityStore< ITEM, TAG > CardinalityStore::getCollectionWithoutTags ( const OpSet< TAG > &  tag  )  const

Return a tagged collection with all tagsets of this one that are nonempty when stripped by the tag `tag' and all tags that imply it.

template<class ITEM, class TAG>
CardinalityStore< ITEM, TAG > CardinalityStore::getCollectionWithoutTagsetsHaving ( const TAG &  tag  )  const

Return the tagged collection with all tagsets of this one that do not contain the tag `tag'.

template<class ITEM, class TAG>
CardinalityStore< ITEM, TAG > CardinalityStore::getCollectionWithoutTagsetsHavingAnyOf ( const OpSet< TAG > &  tag  )  const

Return the tagged collection with all tagsets of this one that do not contain the tags in `tags'.

template<class ITEM, class TAG>
OpSet< TAG > CardinalityStore::getImpliedBy ( const TAG &  tag  )  const

Return the list of tags that the given tag implies.

template<class ITEM, class TAG>
int CardinalityStore::getCardinality ( const TAG &  tag  )  const [virtual]

Get the cardinality of tag `tag' (that is, the number of items who have it).

Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
TAG CardinalityStore::findTagWithMaxCardinalityNotIn ( const OpSet< TAG > &  tags,
int *  card = 0 
) const

template<class ITEM, class TAG>
void CardinalityStore::mergeEquivalentTags (  ) 

template<class ITEM, class TAG>
void CardinalityStore::removeTagsWithCardinalityLessThan ( int  card  ) 

template<class ITEM, class TAG>
void CardinalityStore::output ( Consumer< ITEM, TAG > &  cons  )  const [virtual]

Output all the contents of the collection to a Consumer.

Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.

template<class ITEM, class TAG>
void CardinalityStore::outputHavingTags ( const OpSet< TAG > &  ts,
Consumer< ITEM, TAG > &  consumer 
) const [virtual]

Send to a consumer all the items which are tagged with at least the given tags.

Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.


Member Data Documentation

template<class ITEM, class TAG>
TagContainer Tagcoll::CardinalityStore< ITEM, TAG >::tags [protected]

template<class ITEM, class TAG>
tagsets_t Tagcoll::CardinalityStore< ITEM, TAG >::tagsets [protected]


The documentation for this class was generated from the following files:
Generated on Sat Jan 17 03:27:45 2009 for libtagcoll by  doxygen 1.5.1