tesseract  4.0.0-1-g2a2b
tesseract::UnicharIdArrayUtils Class Reference

#include <ambigs.h>

Static Public Member Functions

static int compare (const UNICHAR_ID *ptr1, const UNICHAR_ID *ptr2)
 
static int find_in (const UnicharIdVector &uid_vec, const UNICHAR_ID uid)
 
static int copy (const UNICHAR_ID src[], UNICHAR_ID dst[])
 
static void print (const UNICHAR_ID array[], const UNICHARSET &unicharset)
 

Detailed Description

Definition at line 56 of file ambigs.h.

Member Function Documentation

◆ compare()

static int tesseract::UnicharIdArrayUtils::compare ( const UNICHAR_ID ptr1,
const UNICHAR_ID ptr2 
)
inlinestatic

Definition at line 62 of file ambigs.h.

62  {
63  for (;;) {
64  const UNICHAR_ID val1 = *ptr1++;
65  const UNICHAR_ID val2 = *ptr2++;
66  if (val1 != val2) {
67  if (val1 == INVALID_UNICHAR_ID) return -1;
68  if (val2 == INVALID_UNICHAR_ID) return 1;
69  if (val1 < val2) return -1;
70  return 1;
71  }
72  if (val1 == INVALID_UNICHAR_ID) return 0;
73  }
74  }
int UNICHAR_ID
Definition: unichar.h:35

◆ copy()

static int tesseract::UnicharIdArrayUtils::copy ( const UNICHAR_ID  src[],
UNICHAR_ID  dst[] 
)
inlinestatic

Definition at line 88 of file ambigs.h.

88  {
89  int i = 0;
90  do {
91  dst[i] = src[i];
92  } while (dst[i++] != INVALID_UNICHAR_ID);
93  return i - 1;
94  }

◆ find_in()

static int tesseract::UnicharIdArrayUtils::find_in ( const UnicharIdVector uid_vec,
const UNICHAR_ID  uid 
)
inlinestatic

Definition at line 78 of file ambigs.h.

79  {
80  for (int i = 0; i < uid_vec.size(); ++i)
81  if (uid_vec[i] == uid) return i;
82  return -1;
83  }

◆ print()

static void tesseract::UnicharIdArrayUtils::print ( const UNICHAR_ID  array[],
const UNICHARSET unicharset 
)
inlinestatic

Definition at line 98 of file ambigs.h.

99  {
100  const UNICHAR_ID *ptr = array;
101  if (*ptr == INVALID_UNICHAR_ID) tprintf("[Empty]");
102  while (*ptr != INVALID_UNICHAR_ID) {
103  tprintf("%s ", unicharset.id_to_unichar(*ptr++));
104  }
105  tprintf("( ");
106  ptr = array;
107  while (*ptr != INVALID_UNICHAR_ID) tprintf("%d ", *ptr++);
108  tprintf(")\n");
109  }
int UNICHAR_ID
Definition: unichar.h:35
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:290

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