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
GENERIC_2D_ARRAY< T > Class Template Reference

`#include <matrix.h>`

Inheritance diagram for GENERIC_2D_ARRAY< T >:

List of all members.

## Public Member Functions
| GENERIC_2D_ARRAY (int dim1, int dim2, const T &empty)
| ~GENERIC_2D_ARRAY ()
bool | Serialize (FILE *fp) const
bool | DeSerialize (bool swap, FILE *fp)
bool | SerializeClasses (FILE *fp) const
bool | DeSerializeClasses (bool swap, FILE *fp)
int | dim1 () const
int | dim2 () const
int | index (int column, int row) const
void | put (int column, int row, const T &thing)
T | get (int column, int row) const
const T & | operator() (int column, int row) const
T & | operator() (int column, int row)
T * | operator[] (int column)
void | delete_matrix_pointers ()

## Detailed Description

### template<class T>
class GENERIC_2D_ARRAY< T >

Definition at line 35 of file matrix.h.

## Constructor & Destructor Documentation

template<class T>

GENERIC_2D_ARRAY< T >::GENERIC_2D_ARRAY | ( | int | dim1,
|  | int | dim2,
|  | const T & | empty
| ) |  |
| inline

Definition at line 40 of file matrix.h.

: empty_(empty), dim1_(dim1), dim2_(dim2) {
array_ = new T[dim1_ * dim2_];
for (int x = 0; x < dim1_; x++)
for (int y = 0; y < dim2_; y++)
this->put(x, y, empty_);
}
template<class T>

GENERIC_2D_ARRAY< T >::~GENERIC_2D_ARRAY | ( |  | ) |
| inline

Definition at line 47 of file matrix.h.

{ delete[] array_; }

## Member Function Documentation

template<class T>

void GENERIC_2D_ARRAY< T >::delete_matrix_pointers | ( |  | ) |
| inline

Definition at line 134 of file matrix.h.

{
for (int x = 0; x < dim1_; x++) {
for (int y = 0; y < dim2_; y++) {
T matrix_cell = this->get(x, y);
if (matrix_cell != empty_)
delete matrix_cell;
}
}
}
template<class T>

bool GENERIC_2D_ARRAY< T >::DeSerialize | ( | bool | swap,
|  | FILE * | fp
| ) |  |
| inline

Definition at line 62 of file matrix.h.

{
if (!DeSerializeSize(swap, fp)) return false;
if (fread(&empty_, sizeof(empty_), 1, fp) != 1) return false;
if (swap) ReverseN(&empty_, sizeof(empty_));
int size = dim1_ * dim2_;
if (fread(array_, sizeof(*array_), size, fp) != size) return false;
if (swap) {
for (int i = 0; i < size; ++i)
ReverseN(&array_[i], sizeof(array_[i]));
}
return true;
}
template<class T>

bool GENERIC_2D_ARRAY< T >::DeSerializeClasses | ( | bool | swap,
|  | FILE * | fp
| ) |  |
| inline

Definition at line 90 of file matrix.h.

{
if (!DeSerializeSize(swap, fp)) return false;
if (!empty_.DeSerialize(swap, fp)) return false;
int size = dim1_ * dim2_;
for (int i = 0; i < size; ++i) {
if (!array_[i].DeSerialize(swap, fp)) return false;
}
return true;
}
template<class T>

int GENERIC_2D_ARRAY< T >::dim1 | ( |  | ) | const
| inline

Definition at line 101 of file matrix.h.

{ return dim1_; }
template<class T>

int GENERIC_2D_ARRAY< T >::dim2 | ( |  | ) | const
| inline

Definition at line 102 of file matrix.h.

{ return dim2_; }
template<class T>

T GENERIC_2D_ARRAY< T >::get | ( | int | column,
|  | int | row
| ) |  | const
| inline

Definition at line 117 of file matrix.h.

{
return array_[this->index(column, row)];
}
template<class T>

int GENERIC_2D_ARRAY< T >::index | ( | int | column,
|  | int | row
| ) |  | const
| inline

Definition at line 107 of file matrix.h.

{
return (column * dim2_ + row);
}
template<class T>

const T& GENERIC_2D_ARRAY< T >::operator() | ( | int | column,
|  | int | row
| ) |  | const
| inline

Definition at line 121 of file matrix.h.

{
return array_[this->index(column, row)];
}
template<class T>

T& GENERIC_2D_ARRAY< T >::operator() | ( | int | column,
|  | int | row
| ) |  |
| inline

Definition at line 124 of file matrix.h.

{
return array_[this->index(column, row)];
}
template<class T>

T* GENERIC_2D_ARRAY< T >::operator[] | ( | int | column | ) |
| inline

Definition at line 129 of file matrix.h.

{
return &array_[this->index(column, 0)];
}
template<class T>

void GENERIC_2D_ARRAY< T >::put | ( | int | column,
|  | int | row,
|  | const T & | thing
| ) |  |
| inline

Definition at line 112 of file matrix.h.

{
array_[this->index(column, row)] = thing;
}
template<class T>

bool GENERIC_2D_ARRAY< T >::Serialize | ( | FILE * | fp | ) | const
| inline

Definition at line 51 of file matrix.h.

{
if (!SerializeSize(fp)) return false;
if (fwrite(&empty_, sizeof(empty_), 1, fp) != 1) return false;
int size = dim1_ * dim2_;
if (fwrite(array_, sizeof(*array_), size, fp) != size) return false;
return true;
}
template<class T>

bool GENERIC_2D_ARRAY< T >::SerializeClasses | ( | FILE * | fp | ) | const
| inline

Definition at line 77 of file matrix.h.

{
if (!SerializeSize(fp)) return false;
if (!empty_.Serialize(fp)) return false;
int size = dim1_ * dim2_;
for (int i = 0; i < size; ++i) {
if (!array_[i].Serialize(fp)) return false;
}
return true;
}

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

- /mnt/data/src/tesseract-ocr/ccstruct/matrix.h