tesseract v5.3.3.20231005
tesseract::UnicharIdArrayUtils Class Reference

#include <ambigs.h>

Static Public Member Functions

static int compare (const UNICHAR_ID *ptr1, const UNICHAR_ID *ptr2)
 
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 52 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 58 of file ambigs.h.

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

◆ copy()

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

Definition at line 83 of file ambigs.h.

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

◆ print()

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

Definition at line 93 of file ambigs.h.

93 {
94 const UNICHAR_ID *ptr = array;
95 if (*ptr == INVALID_UNICHAR_ID) {
96 tprintf("[Empty]");
97 }
98 while (*ptr != INVALID_UNICHAR_ID) {
99 tprintf("%s ", unicharset.id_to_unichar(*ptr++));
100 }
101 tprintf("( ");
102 ptr = array;
103 while (*ptr != INVALID_UNICHAR_ID) {
104 tprintf("%d ", *ptr++);
105 }
106 tprintf(")\n");
107 }
void tprintf(const char *format,...)
Definition: tprintf.cpp:41

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