Iterators

struct TmeIterator

Iterator API.

A TmeIterator is a wrapper around a function that gets called for every element matched by a query submitted to the reasoner. By providing a generic context pointer, you can plug any data structure (loggers, collections, etc.) which allows for arbitrarily complex queries.

The iterator function returns a boolean that can be used to control iteration: by returning true iteration goes on to the next element, while returning false causes it to stop. This is useful if, for example, you want to find the first element matching certain criteria.

Note

This is not a real data structure, though it is declared as such for better grouping in the generated documentation.

Subclassed by TmeABoxIterator, TmeKBConceptIterator, TmeKBIndividualIterator, TmeTaxonomyIterator, TmeTBoxIterator

Related

tme_iterator_init(CTX, FOR_EACH)

Initializes an iterator.

Return

Initialized iterator.

Parameters
  • CTX: Iterator context, can be anything.

  • FOR_EACH: Pointer to a function called by the iterator for every element.

TBox iterator

struct TmeTBoxIterator : public TmeIterator

TBox iterator.

Public Members

void *ctx

The iterator context, can be anything.

bool (*for_each)(void *ctx, TmeEntityPtr concept, TmeSemDesc *desc)

Pointer to a function called by the iterator for every element.

ABox iterator

struct TmeABoxIterator : public TmeIterator

ABox iterator.

Public Members

void *ctx

The iterator context, can be anything.

bool (*for_each)(void *ctx, TmeEntityPtr individual, TmeSemDesc *desc, TmeABoxEntryType type)

Pointer to a function called by the iterator for every element.

KB concept iterator

struct TmeKBConceptIterator : public TmeIterator

KBConcept iterator.

Public Members

void *ctx

The iterator context, can be anything.

bool (*for_each)(void *ctx, TmeEntityPtr)

Pointer to a function called by the iterator for every element.

KB individual iterator

struct TmeKBIndividualIterator : public TmeIterator

KBIndividual iterator.

Public Members

void *ctx

The iterator context, can be anything.

bool (*for_each)(void *ctx, TmeEntityPtr individual, TmeABoxEntryType type)

Pointer to a function called by the iterator for every element.

Taxonomy iterator

struct TmeTaxonomyIterator : public TmeIterator

Taxonomy iterator.

Taxonomy iterator.

Public Members

void *ctx

The iterator context, can be anything.

bool (*for_each)(void *ctx, TmeEntityPtr concept)

Pointer to a function called by the iterator for every element.