Tesseract
3.02
|
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 () |
Definition at line 53 of file kdtree.cpp.
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_];
}
Definition at line 87 of file kdtree.cpp.
{
delete []elements_;
}
Definition at line 70 of file kdtree.cpp.
{ return elements_; }
int MinK< Key, Value >::elements_count | ( | ) | [inline] |
Definition at line 69 of file kdtree.cpp.
{ return elements_count_; }
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; }
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; }