Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
UnicityTable< T > Class Template Reference

`#include <unicity_table.h>`

Inheritance diagram for UnicityTable< T >:

List of all members.

## Public Member Functions
| UnicityTable ()
| ~UnicityTable ()
| Clear the structures and deallocate internal structures.
void | reserve (int size)
int | size () const
| Return the size used.
const T & | get (int id) const
| Return the object from an id.
T * | get_mutable (int id)
int | get_id (T object) const
bool | contains (T object) const
| Return true if T is in the table.
T | contains_id (int id) const
| Return true if the id is valid.
int | push_back (T object)
| Add an element in the table.
void | set_clear_callback (TessCallback1< T > *cb)
void | set_compare_callback (TessResultCallback2< bool, T const &, T const & > *cb)
void | clear ()
void | move (UnicityTable< T > *from)
bool | write (FILE *f, TessResultCallback2< bool, FILE *, T const & > *cb) const
bool | read (FILE *f, TessResultCallback3< bool, FILE *, T *, bool > *cb, bool swap)
| swap is used to switch the endianness.

## Detailed Description

### template<typename T>
class UnicityTable< T >

Definition at line 33 of file unicity_table.h.

## Constructor & Destructor Documentation

template<typename T >

UnicityTable< T >::UnicityTable | ( |  | ) |

Definition at line 108 of file unicity_table.h.

:
compare_cb_(0) {
}
template<typename T >

UnicityTable< T >::~UnicityTable | ( |  | ) |

Clear the structures and deallocate internal structures.

Definition at line 114 of file unicity_table.h.

{
clear();
}

## Member Function Documentation

template<typename T >

void UnicityTable< T >::clear | ( |  | ) |

Clear the table, calling the callback function if any. All the owned Callbacks are also deleted. If you don't want the Callbacks to be deleted, before calling clear, set the callback to NULL.

Definition at line 185 of file unicity_table.h.

{
table_.clear();
}
template<typename T>

bool UnicityTable< T >::contains | ( | T | object | ) | const

Return true if T is in the table.

Definition at line 154 of file unicity_table.h.

{
return get_id(object) != -1;
}
template<typename T >

T UnicityTable< T >::contains_id | ( | int | id | ) | const

Return true if the id is valid.

Definition at line 142 of file unicity_table.h.

{
return table_.contains_index(id);
}
template<typename T >

const T & UnicityTable< T >::get | ( | int | id | ) | const

Return the object from an id.

Definition at line 132 of file unicity_table.h.

{
return table_.get(id);
}
template<typename T>

int UnicityTable< T >::get_id | ( | T | object | ) | const

Return the id of the T object. This method NEEDS a compare_callback to be passed to set_compare_callback.

Definition at line 148 of file unicity_table.h.

{
return table_.get_index(object);
}
template<typename T >

T * UnicityTable< T >::get_mutable | ( | int | id | ) |

Definition at line 137 of file unicity_table.h.

{
return &(table_.get(id));
}
template<typename T>

void UnicityTable< T >::move | ( | UnicityTable< T > * | from | ) |

This method clear the current object, then, does a shallow copy of its argument, and finally invalidate its argument.

Definition at line 204 of file unicity_table.h.

{
table_.move(&from->table_);
}
template<typename T>

int UnicityTable< T >::push_back | ( | T | object | ) |

Add an element in the table.

Definition at line 160 of file unicity_table.h.

{
int idx = get_id(object);
if (idx == -1) {
idx = table_.push_back(object);
}
return idx;
}
template<typename T>

bool UnicityTable< T >::read | ( | FILE * | f,
|  | TessResultCallback3< bool, FILE *, T *, bool > * | cb,
|  | bool | swap
| ) |  |

swap is used to switch the endianness.

Definition at line 196 of file unicity_table.h.

{
return table_.read(f, cb, swap);
}
template<typename T >

void UnicityTable< T >::reserve | ( | int | size | ) |

Reserve some memory. If there is size or more elements, the table will then allocate size * 2 elements.

Definition at line 126 of file unicity_table.h.

{
table_.reserve(size);
}
template<typename T>

void UnicityTable< T >::set_clear_callback | ( | TessCallback1< T > * | cb | ) |

Add a callback to be called to delete the elements when the table took their ownership.

Definition at line 171 of file unicity_table.h.

{
table_.set_clear_callback(cb);
}
template<typename T>

void UnicityTable< T >::set_compare_callback | ( | TessResultCallback2< bool, T const &, T const & > * | cb | ) |

Add a callback to be called to compare the elements when needed (contains, get_id, ...)

Definition at line 178 of file unicity_table.h.

{
table_.set_compare_callback(cb);
compare_cb_ = cb;
}
template<typename T >

int UnicityTable< T >::size | ( |  | ) | const

Return the size used.

Definition at line 119 of file unicity_table.h.

{
return table_.size();
}
template<typename T>

bool UnicityTable< T >::write | ( | FILE * | f,
|  | TessResultCallback2< bool, FILE *, T const & > * | cb
| ) |  | const

Read/Write the table to a file. This does NOT read/write the callbacks. The Callback given must be permanent since they will be called more than once. The given callback will be deleted at the end. Returns false on read/write error.

Definition at line 190 of file unicity_table.h.

{
return table_.write(f, cb);
}

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

- /mnt/data/src/tesseract-ocr/ccutil/unicity_table.h