OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
opencog::TypeIndex Class Reference

#include <TypeIndex.h>

+ Inheritance diagram for opencog::TypeIndex:
+ Collaboration diagram for opencog::TypeIndex:

Classes

class  iterator
 

Public Member Functions

 TypeIndex (void)
 
void resize (void)
 
void insertAtom (Atom *a)
 
void removeAtom (Atom *a)
 
size_t getNumAtomsOfType (Type type, bool subclass) const
 
iterator begin (Type, bool) const
 
iterator end (void) const
 
- Public Member Functions inherited from opencog::FixedIntegerIndex
 ~FixedIntegerIndex ()
 
void insert (size_t i, Atom *a)
 
void remove (size_t i, Atom *a)
 
size_t size (size_t i) const
 
size_t size (void) const
 

Private Attributes

size_t num_types
 

Additional Inherited Members

- Protected Member Functions inherited from opencog::FixedIntegerIndex
void resize (size_t sz)
 
- Protected Attributes inherited from opencog::FixedIntegerIndex
std::vector< UnorderedAtomSetidx
 

Detailed Description

Implements an integer index as an RB-tree (C++ set) That is, given an atom Type, this returns all of the Handles for that Type.

The primary interface for this is an iterator, and that is because the index will typically contain millions of atoms, and this is far too much to try to return in some temporary array. Iterating is much safer.

Todo:
The iterator is NOT thread-safe against the insertion or removal of atoms! Either inserting or removing an atom will cause the iterator references to be freed, leading to mystery crashes!

Definition at line 52 of file TypeIndex.h.

Constructor & Destructor Documentation

TypeIndex::TypeIndex ( void  )

Definition at line 28 of file TypeIndex.cc.

References resize().

Member Function Documentation

size_t TypeIndex::getNumAtomsOfType ( Type  type,
bool  subclass 
) const
void opencog::TypeIndex::insertAtom ( Atom a)
inline

Definition at line 59 of file TypeIndex.h.

References python.create_atoms_by_type::a, opencog::Atom::getType(), and opencog::FixedIntegerIndex::insert().

+ Here is the caller graph for this function:

void opencog::TypeIndex::removeAtom ( Atom a)
inline

Definition at line 63 of file TypeIndex.h.

References python.create_atoms_by_type::a, and opencog::Atom::getType().

+ Here is the caller graph for this function:

void TypeIndex::resize ( void  )

Definition at line 33 of file TypeIndex.cc.

References opencog::classserver(), opencog::ClassServer::getNumberOfClasses(), num_types, and opencog::FixedIntegerIndex::resize().

+ Here is the caller graph for this function:

Member Data Documentation

size_t opencog::TypeIndex::num_types
private

Definition at line 55 of file TypeIndex.h.


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