tesseract  3.03
tesseract::DawgPositionVector Class Reference

#include <dawg.h>

Inheritance diagram for tesseract::DawgPositionVector:
GenericVector< DawgPosition >

List of all members.

Public Member Functions

 ~DawgPositionVector ()
 Overload destructor, since clear() does not delete data_[] any more.
void clear ()
bool add_unique (const DawgPosition &new_pos, bool debug, const char *debug_msg)

Detailed Description

Definition at line 369 of file dawg.h.


Constructor & Destructor Documentation

Overload destructor, since clear() does not delete data_[] any more.

Definition at line 372 of file dawg.h.

                        {
    if (size_reserved_ > 0) {
      delete[] data_;
      size_used_ = 0;
      size_reserved_ = 0;
    }
  }

Member Function Documentation

bool tesseract::DawgPositionVector::add_unique ( const DawgPosition new_pos,
bool  debug,
const char *  debug_msg 
) [inline]

Adds an entry for the given dawg_index with the given node to the vec. Returns false if the same entry already exists in the vector, true otherwise.

Definition at line 385 of file dawg.h.

                                                {
    for (int i = 0; i < size_used_; ++i) {
      if (data_[i] == new_pos) return false;
    }
    push_back(new_pos);
    if (debug) {
      tprintf("%s[%d, " REFFORMAT "] [punc: " REFFORMAT "%s]\n",
              debug_msg, new_pos.dawg_index, new_pos.dawg_ref,
              new_pos.punc_ref, new_pos.back_to_punc ? " returned" : "");
    }
    return true;
  }

Overload clear() in order to avoid allocating/deallocating memory when clearing the vector and re-inserting entries into it later.

Reimplemented from GenericVector< DawgPosition >.

Definition at line 381 of file dawg.h.

{ size_used_ = 0; }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines