tesseract  5.0.0-alpha-619-ge9db
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 49 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 55 of file ambigs.h.

55  {
56  for (;;) {
57  const UNICHAR_ID val1 = *ptr1++;
58  const UNICHAR_ID val2 = *ptr2++;
59  if (val1 != val2) {
60  if (val1 == INVALID_UNICHAR_ID) return -1;
61  if (val2 == INVALID_UNICHAR_ID) return 1;
62  if (val1 < val2) return -1;
63  return 1;
64  }
65  if (val1 == INVALID_UNICHAR_ID) return 0;
66  }
67  }

◆ copy()

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

Definition at line 81 of file ambigs.h.

81  {
82  int i = 0;
83  do {
84  dst[i] = src[i];
85  } while (dst[i++] != INVALID_UNICHAR_ID);
86  return i - 1;
87  }

◆ find_in()

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

Definition at line 71 of file ambigs.h.

72  {
73  for (int i = 0; i < uid_vec.size(); ++i)
74  if (uid_vec[i] == uid) return i;
75  return -1;
76  }

◆ print()

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

Definition at line 91 of file ambigs.h.

92  {
93  const UNICHAR_ID *ptr = array;
94  if (*ptr == INVALID_UNICHAR_ID) tprintf("[Empty]");
95  while (*ptr != INVALID_UNICHAR_ID) {
96  tprintf("%s ", unicharset.id_to_unichar(*ptr++));
97  }
98  tprintf("( ");
99  ptr = array;
100  while (*ptr != INVALID_UNICHAR_ID) tprintf("%d ", *ptr++);
101  tprintf(")\n");
102  }

The documentation for this class was generated from the following file:
UNICHAR_ID
int UNICHAR_ID
Definition: unichar.h:36
tprintf
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:34
UNICHARSET::id_to_unichar
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:290