radicalArray

radicalArray — RadicalArray is an array of radical pointers.

Stability Level

Stable, unless otherwise indicated

Synopsis



RadicalArray*       radicalArray_new                    ();
RadicalArray*       radicalArray_sized_new              (guint reserved_size);
RadicalType         radicalArray_get_radicalType        (RadicalArray *self);
void                radicalArray_set_radicalType        (RadicalArray *self,
                                                         RadicalType type);
gpointer            radicalArray_free                   (RadicalArray *self,
                                                         gboolean free_segment);
RadicalArray*       radicalArray_clone                  (RadicalArray *self);
void                radicalArray_copy                   (RadicalArray *self,
                                                         RadicalArray *src);
void                radicalArray_reset                  (RadicalArray *self);
guint               radicalArray_size                   (RadicalArray *self);
void                radicalArray_append                 (RadicalArray *self,
                                                         Radical *rad);
gboolean            radicalArray_has_radicalCode        (RadicalArray *self,
                                                         RadicalCode code);
Radical*            radicalArray_index                  (RadicalArray *self,
                                                         guint index);
Radical*            radicalArray_find_by_code           (RadicalArray *self,
                                                         RadicalCode rCode);
gboolean            radicalArray_is_empty               (RadicalArray *self);
gboolean            radicalArray_foreach                (RadicalArray *self,
                                                         ForeachCallbackFunc func,
                                                         gpointer userdata);
void                radicalArray_sort                   (RadicalArray *self,
                                                         GCompareFunc func);

Description

RadicalArray is an array of radical pointers. Unlike RadicalList, which only stores radicalCode, RadicalArray stores radical pointers. RadicalList is preferred when:

  • Huge set of radicals is expected.

  • The radical code is in UniCode.

  • Manipulate radicals through datafile.

Instead, RadicalArray is more suitable when:

  • Small set of radicals

  • Storing RawStrokes (whose radical code are usually negative)

  • Datafile is not necessary.

Details

radicalArray_new ()

RadicalArray*       radicalArray_new                    ();

Allocate a new radical array.

Returns :

a new radical array

radicalArray_sized_new ()

RadicalArray*       radicalArray_sized_new              (guint reserved_size);

Allocate a new radical array with given size

reserved_size :

size of new array

Returns :

a new radical array

radicalArray_get_radicalType ()

RadicalType         radicalArray_get_radicalType        (RadicalArray *self);

Get the RadicalType of Radical Array.

self :

the radical array

Returns :

Radical type of self.

radicalArray_set_radicalType ()

void                radicalArray_set_radicalType        (RadicalArray *self,
                                                         RadicalType type);

Set the RadicalType of Radical Array.

self :

the radical array

type :

type of the radical

radicalArray_free ()

gpointer            radicalArray_free                   (RadicalArray *self,
                                                         gboolean free_segment);

Set the RadicalType of Radical Array.

self :

the radical array

free_segment :

Returns :


radicalArray_clone ()

RadicalArray*       radicalArray_clone                  (RadicalArray *self);

Return deep-copied clone of the radical array. Use radicalArray_free() to free the returned clone.

self :

the radical array

Returns :

A deep-copied clone of self

radicalArray_copy ()

void                radicalArray_copy                   (RadicalArray *self,
                                                         RadicalArray *src);

Deep copy from source radical array .

self :

the radical array

src :

the source radical array to be copied from.

radicalArray_reset ()

void                radicalArray_reset                  (RadicalArray *self);

Reset the radical array by removing all elements.

self :

the radical array

radicalArray_size ()

guint               radicalArray_size                   (RadicalArray *self);

Returns the number of radicals in the radical array.

self :

the radical array

Returns :

number of radicals in the radical array

radicalArray_append ()

void                radicalArray_append                 (RadicalArray *self,
                                                         Radical *rad);

Appends radical to radical array.

self :

the radical array

rad :

the radical to be appended.

radicalArray_has_radicalCode ()

gboolean            radicalArray_has_radicalCode        (RadicalArray *self,
                                                         RadicalCode code);

self :

code :

Returns :


radicalArray_index ()

Radical*            radicalArray_index                  (RadicalArray *self,
                                                         guint index);

Returns the radical at given index.

self :

the radical array

index :

Returns :

the radical in self at index aindex.

radicalArray_find_by_code ()

Radical*            radicalArray_find_by_code           (RadicalArray *self,
                                                         RadicalCode rCode);

Returns the first radical which has the specified code in radical array.

self :

the radical array.

rCode :

the first radical with the same radical code

Returns :

the first radical which has radical code in radical array, NULL if not found.

radicalArray_is_empty ()

gboolean            radicalArray_is_empty               (RadicalArray *self);

Returns whether the radical array is empty.

self :

the radical array.

Returns :

TRUE if self is either NULL or has no elements, FALSE otherwise.

radicalArray_foreach ()

gboolean            radicalArray_foreach                (RadicalArray *self,
                                                         ForeachCallbackFunc func,
                                                         gpointer userdata);

Perform a function for each element of the radical array.

self :

the radical array.

func :

callback function to perform for each radical in self.

userdata :

argument for passing to func.

Returns :

TRUE if every radicals are treated; FALSE indicates the iteration is stopped midway.

radicalArray_sort ()

void                radicalArray_sort                   (RadicalArray *self,
                                                         GCompareFunc func);

Sort radicals according to the comparison callback function.

self :

the radical array.

func :

comparison callback function for comparing two radicals.

See Also

writRecognRadical, writRecognRadical_list, RadicalArray