All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tesseract::DawgPositionVector Class Reference

#include <dawg.h>

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

Public Member Functions

 ~DawgPositionVector ()
 Overload destructor, since clear() does not delete data_[] any more. More...
 
void clear ()
 
bool add_unique (const DawgPosition &new_pos, bool debug, const char *debug_msg)
 
- Public Member Functions inherited from GenericVector< DawgPosition >
 GenericVector ()
 
 GenericVector (int size, DawgPositioninit_val)
 
 GenericVector (const GenericVector &other)
 
GenericVector< DawgPosition > & operator+= (const GenericVector &other)
 
void operator+= (DawgPositiont)
 
GenericVector< DawgPosition > & operator= (const GenericVector &other)
 
 ~GenericVector ()
 
void reserve (int size)
 
void double_the_size ()
 
void init_to_size (int size, DawgPositiont)
 
void resize_no_init (int size)
 
int size () const
 
int size_reserved () const
 
int length () const
 
bool empty () const
 
DawgPosition & get (int index) const
 
DawgPosition & back () const
 
DawgPosition & operator[] (int index) const
 
DawgPosition pop_back ()
 
int get_index (DawgPositionobject) const
 
bool contains (DawgPositionobject) const
 
DawgPosition contains_index (int index) const
 
int push_back (DawgPositionobject)
 
int push_back_new (DawgPositionobject)
 
int push_front (DawgPositionobject)
 
void set (DawgPositiont, int index)
 
void insert (DawgPositiont, int index)
 
void remove (int index)
 
void truncate (int size)
 
void set_clear_callback (TessCallback1< DawgPosition > *cb)
 
void set_compare_callback (TessResultCallback2< bool, DawgPositionconst &, DawgPositionconst & > *cb)
 
void clear ()
 
void delete_data_pointers ()
 
void move (GenericVector< DawgPosition > *from)
 
bool write (FILE *f, TessResultCallback2< bool, FILE *, DawgPositionconst & > *cb) const
 
bool read (FILE *f, TessResultCallback3< bool, FILE *, DawgPosition *, bool > *cb, bool swap)
 
bool Serialize (FILE *fp) const
 
bool Serialize (tesseract::TFile *fp) const
 
bool DeSerialize (bool swap, FILE *fp)
 
bool DeSerialize (bool swap, tesseract::TFile *fp)
 
bool SerializeClasses (FILE *fp) const
 
bool SerializeClasses (tesseract::TFile *fp) const
 
bool DeSerializeClasses (bool swap, FILE *fp)
 
bool DeSerializeClasses (bool swap, tesseract::TFile *fp)
 
void reverse ()
 
void sort ()
 
void sort (int(*comparator)(const void *, const void *))
 
bool bool_binary_search (const DawgPosition &target) const
 
int binary_search (const DawgPosition &target) const
 
void compact_sorted ()
 
void compact (TessResultCallback1< bool, int > *delete_cb)
 
DawgPosition dot_product (const GenericVector< DawgPosition > &other) const
 
int choose_nth_item (int target_index)
 
void swap (int index1, int index2)
 
bool WithinBounds (const DawgPosition &rangemin, const DawgPosition &rangemax) const
 

Additional Inherited Members

- Static Public Member Functions inherited from GenericVector< DawgPosition >
static DawgPosition * double_the_size_memcpy (int current_size, DawgPosition *data)
 
- Protected Member Functions inherited from GenericVector< DawgPosition >
int choose_nth_item (int target_index, int start, int end, unsigned int *seed)
 
void init (int size)
 
- Protected Attributes inherited from GenericVector< DawgPosition >
inT32 size_used_
 
inT32 size_reserved_
 
DawgPosition * data_
 
TessCallback1< DawgPosition > * clear_cb_
 
TessResultCallback2< bool,
DawgPositionconst
&, DawgPositionconst & > * 
compare_cb_
 
- Static Protected Attributes inherited from GenericVector< DawgPosition >
static const int kDefaultVectorSize
 

Detailed Description

Definition at line 369 of file dawg.h.

Constructor & Destructor Documentation

tesseract::DawgPositionVector::~DawgPositionVector ( )
inline

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

Definition at line 372 of file dawg.h.

372  {
373  if (size_reserved_ > 0) {
374  delete[] data_;
375  size_used_ = 0;
376  size_reserved_ = 0;
377  }
378  }

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.

387  {
388  for (int i = 0; i < size_used_; ++i) {
389  if (data_[i] == new_pos) return false;
390  }
391  push_back(new_pos);
392  if (debug) {
393  tprintf("%s[%d, " REFFORMAT "] [punc: " REFFORMAT "%s]\n",
394  debug_msg, new_pos.dawg_index, new_pos.dawg_ref,
395  new_pos.punc_ref, new_pos.back_to_punc ? " returned" : "");
396  }
397  return true;
398  }
int push_back(DawgPositionobject)
#define tprintf(...)
Definition: tprintf.h:31
#define REFFORMAT
Definition: dawg.h:92
void tesseract::DawgPositionVector::clear ( )
inline

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

Definition at line 381 of file dawg.h.


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