#include <CardinalityStore.h>
Inheritance diagram for Tagcoll::CardinalityStore< ITEM, TAG >:
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 |
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.
typedef std::map<OpSet<TAG>, OpSet<ITEM> > Tagcoll::CardinalityStore< ITEM, TAG >::tagsets_t |
Reimplemented in Tagcoll::Normalizer< ITEM, TAG >, and Tagcoll::Graph< ITEM, TAG >.
typedef tagsets_t::const_iterator Tagcoll::CardinalityStore< ITEM, TAG >::const_iterator |
Iterators support.
typedef tagsets_t::iterator Tagcoll::CardinalityStore< ITEM, TAG >::iterator |
Iterators support.
Tagcoll::CardinalityStore< ITEM, TAG >::CardinalityStore | ( | ) | [inline] |
virtual Tagcoll::CardinalityStore< ITEM, TAG >::~CardinalityStore | ( | ) | [inline, virtual] |
OpSet< TAG > CardinalityStore::getImplyingOneOf | ( | const OpSet< TAG > & | tags | ) | const [inline, protected] |
Get the list of tags that imply one of the tags in `tags'.
void CardinalityStore::consumeItem | ( | const ITEM & | item, | |
const OpSet< TAG > & | tags | |||
) | [inline, protected, virtual] |
void CardinalityStore::consumeItems | ( | const OpSet< ITEM > & | items, | |
const OpSet< TAG > & | tags | |||
) | [inline, protected, virtual] |
Process a set of items identically tagged, with their tags.
Reimplemented from Tagcoll::Consumer< ITEM, TAG >.
OpSet< ITEM > CardinalityStore::getItemsHavingTag | ( | const TAG & | tag | ) | const [inline, protected, virtual] |
Get the items which are tagged with at least the tag `tag'.
Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.
OpSet< ITEM > CardinalityStore::getItemsHavingTags | ( | const OpSet< TAG > & | tags | ) | const [inline, protected, virtual] |
Get the items which are tagged with at least the tags `tags'.
Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.
OpSet< TAG > CardinalityStore::getTagsOfItem | ( | const ITEM & | item | ) | const [inline, protected, virtual] |
Get the tags attached to an item.
item | The item to query |
Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.
OpSet< TAG > CardinalityStore::getTagsOfItems | ( | const OpSet< ITEM > & | items | ) | const [inline, protected, virtual] |
Get all the tags attached to the items in a set.
items | The items to query |
Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.
iterator Tagcoll::CardinalityStore< ITEM, TAG >::begin | ( | ) | [inline] |
Iterators support.
iterator Tagcoll::CardinalityStore< ITEM, TAG >::end | ( | ) | [inline] |
Iterators support.
const_iterator Tagcoll::CardinalityStore< ITEM, TAG >::begin | ( | ) | const [inline] |
Iterators support.
const_iterator Tagcoll::CardinalityStore< ITEM, TAG >::end | ( | ) | const [inline] |
Iterators support.
int CardinalityStore::itemCount | ( | ) | const [inline] |
Get the total number of items in this collection.
int Tagcoll::CardinalityStore< ITEM, TAG >::tagCount | ( | ) | const [inline] |
Get the number of different tags in this collection.
int Tagcoll::CardinalityStore< ITEM, TAG >::tagsetCount | ( | ) | const [inline] |
Get the number of different tag sets in this collection.
OpSet< ITEM > CardinalityStore::getItemsExactMatch | ( | const OpSet< TAG > & | ts | ) | const [inline] |
Get the set of items with exactly the given tagset.
bool CardinalityStore::hasItem | ( | const ITEM & | item | ) | const [inline] |
bool Tagcoll::CardinalityStore< ITEM, TAG >::hasTag | ( | const TAG & | tag | ) | const [inline, virtual] |
Check if the collection contains a tag.
tag | The tag to look for |
Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.
OpSet< TAG > CardinalityStore::getAllTags | ( | ) | const [inline, virtual] |
Get the set of all the tags in this collection.
Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.
OpSet< ITEM > CardinalityStore::getTaggedItems | ( | ) | const [inline, virtual] |
Get the set of all the items that have tags according to this collection.
Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.
OpSet< TAG > CardinalityStore::getCompanionTags | ( | const OpSet< TAG > & | tags | ) | const [inline, 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 >.
OpSet< ITEM > CardinalityStore::getCompanionItems | ( | const OpSet< TAG > & | ts | ) | const [inline] |
Get the set of all items in this collection whose tagsets contain `ts'.
map< ITEM, OpSet< TAG > > CardinalityStore::getCompanionItemsAndTagsets | ( | const OpSet< TAG > & | ts | ) | const [inline] |
Get the set of all items in this collection whose tagsets contain `ts'.
OpSet< ITEM > CardinalityStore::getRelatedItems | ( | const OpSet< TAG > & | tags, | |
int | maxdistance = 1 | |||
) | const [inline, 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 >.
list< OpSet< TAG > > CardinalityStore::getRelatedTagsets | ( | const OpSet< TAG > & | ts, | |
int | maxdistance = 1 | |||
) | const [inline] |
Get the list of tagsets related to the given one, with distance > 0 and <= maxdistance.
void CardinalityStore::applyChange | ( | const PatchList< ITEM, TAG > & | change | ) | [inline, 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 >.
CardinalityStore< ITEM, TAG > CardinalityStore::getChildCollection | ( | const TAG & | tag | ) | const [inline] |
Return a tagged collection with all tagsets of this one that contain the tag `tag', but with the tag removed.
CardinalityStore< ITEM, TAG > CardinalityStore::getCollectionWithoutTags | ( | const OpSet< TAG > & | tag | ) | const [inline] |
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 > CardinalityStore::getCollectionWithoutTagsetsHaving | ( | const TAG & | tag | ) | const [inline] |
Return the tagged collection with all tagsets of this one that do not contain the tag `tag'.
CardinalityStore< ITEM, TAG > CardinalityStore::getCollectionWithoutTagsetsHavingAnyOf | ( | const OpSet< TAG > & | tag | ) | const [inline] |
Return the tagged collection with all tagsets of this one that do not contain the tags in `tags'.
OpSet< TAG > CardinalityStore::getImpliedBy | ( | const TAG & | tag | ) | const [inline] |
Return the list of tags that the given tag implies.
int CardinalityStore::getCardinality | ( | const TAG & | tag | ) | const [inline, virtual] |
Get the cardinality of tag `tag' (that is, the number of items who have it).
Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.
TAG CardinalityStore::findTagWithMaxCardinalityNotIn | ( | const OpSet< TAG > & | tags, | |
int * | card = 0 | |||
) | const [inline] |
void CardinalityStore::mergeEquivalentTags | ( | ) | [inline] |
void CardinalityStore::removeTagsWithCardinalityLessThan | ( | int | card | ) | [inline] |
void CardinalityStore::output | ( | Consumer< ITEM, TAG > & | consumer | ) | const [inline, virtual] |
Output all the contents of the collection to a Consumer.
Implements Tagcoll::ReadonlyCollection< ITEM, TAG >.
void CardinalityStore::outputHavingTags | ( | const OpSet< TAG > & | tags, | |
Consumer< ITEM, TAG > & | consumer | |||
) | const [inline, virtual] |
Send to a consumer all the items which are tagged with at least the given tags.
Reimplemented from Tagcoll::ReadonlyCollection< ITEM, TAG >.
TagContainer Tagcoll::CardinalityStore< ITEM, TAG >::tags [protected] |
tagsets_t Tagcoll::CardinalityStore< ITEM, TAG >::tagsets [protected] |