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
Classes | Public Member Functions
MinK< Key, Value > Class Template Reference

List of all members.

## Classes
struct | Element

## Public Member Functions
| MinK (Key max_key, int k)
| ~MinK ()
bool | insert (Key k, Value v)
const Key & | max_insertable_key ()
int | elements_count ()
const Element * | elements ()

## Detailed Description

### template<typename Key, typename Value>
class MinK< Key, Value >

Definition at line 53 of file kdtree.cpp.

## Constructor & Destructor Documentation

template<typename Key, typename Value >

MinK< Key, Value >::MinK | ( | Key | max_key,
|  | int | k
| ) |  |

Definition at line 81 of file kdtree.cpp.

:
max_key_(max_key), elements_count_(0), k_(k < 1 ? 1 : k), max_index_(0) {
elements_ = new Element[k_];
}
template<typename Key , typename Value >

MinK< Key, Value >::~MinK | ( |  | ) |

Definition at line 87 of file kdtree.cpp.

{
delete []elements_;
}

## Member Function Documentation

template<typename Key, typename Value>

const Element* MinK< Key, Value >::elements | ( |  | ) |
| inline

Definition at line 70 of file kdtree.cpp.

{ return elements_; }
template<typename Key, typename Value>

int MinK< Key, Value >::elements_count | ( |  | ) |
| inline

Definition at line 69 of file kdtree.cpp.

{ return elements_count_; }
template<typename Key, typename Value>

bool MinK< Key, Value >::insert | ( | Key | k,
|  | Value | v
| ) |  |

Definition at line 99 of file kdtree.cpp.

{
if (elements_count_ < k_) {
elements_[elements_count_++] = Element(key, value);
if (key > elements_[max_index_].key)
max_index_ = elements_count_ - 1;
return true;
} else if (key < elements_[max_index_].key) {
// evict the largest element.
elements_[max_index_] = Element(key, value);
// recompute max_index_
for (int i = 0; i < elements_count_; i++) {
if (elements_[i].key > elements_[max_index_].key)
max_index_ = i;
}
return true;
}
return false;
}
template<typename Key , typename Value >

const Key & MinK< Key, Value >::max_insertable_key | ( |  | ) |

Definition at line 92 of file kdtree.cpp.

{
if (elements_count_ < k_)
return max_key_;
return elements_[max_index_].key;
}

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

- /mnt/data/src/tesseract-ocr/classify/kdtree.cpp