tesseract  4.0.0-1-g2a2b
SORTED_FLOATS Class Reference

#include <sortflts.h>

Public Member Functions

 SORTED_FLOATS ()
 
SORTED_FLOATS::add

Add a new entry to the sorted list of floats.

void add (float value, int32_t key)
 
SORTED_FLOATS::remove

Remove an entry from the sorted list of floats.

void remove (int32_t key)
 
SORTED_FLOATS::operator[]

Return the floating point value of the given index into the list.

float operator[] (int32_t index)
 

Detailed Description

Definition at line 42 of file sortflts.h.

Constructor & Destructor Documentation

◆ SORTED_FLOATS()

SORTED_FLOATS::SORTED_FLOATS ( )
inline

empty constructor

Definition at line 46 of file sortflts.h.

46  {
47  it.set_to_list (&list);
48  }

Member Function Documentation

◆ add()

void SORTED_FLOATS::add ( float  value,
int32_t  key 
)

add sample

Parameters
valuesample float
keyretrieval key

Definition at line 27 of file sortflts.cpp.

29  {
30  SORTED_FLOAT *new_float = new SORTED_FLOAT (value, key);
31 
32  if (list.empty ())
33  it.add_after_stay_put (new_float);
34  else {
35  it.move_to_first ();
36  while (!it.at_last () && it.data ()->entry < value)
37  it.forward ();
38  if (it.data ()->entry < value)
39  it.add_after_stay_put (new_float);
40  else
41  it.add_before_stay_put (new_float);
42  }
43 }

◆ operator[]()

float SORTED_FLOATS::operator[] ( int32_t  index)

index to list

Parameters
indexitem to get

Definition at line 72 of file sortflts.cpp.

74  {
75  it.move_to_first ();
76  return it.data_relative (index)->entry;
77 }

◆ remove()

void SORTED_FLOATS::remove ( int32_t  key)

delete sample

Parameters
keykey to delete

Definition at line 52 of file sortflts.cpp.

53  {
54  if (!list.empty ()) {
55  for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
56  if (it.data ()->address == key) {
57  delete it.extract ();
58  return;
59  }
60  }
61  }
62 }

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