cutil/tessarray.h File Reference

#include <stdio.h>

Go to the source code of this file.

Classes

Defines

Typedefs

Functions


Define Documentation

#define array_count (  )     ((a)->top)

Return the value of the number of elements currently in the array.

Definition at line 76 of file tessarray.h.

Referenced by any_shared_split_points(), append_number_choices(), array_insert(), array_new(), array_push(), choose_best_seam(), chop_word_main(), classify_piece(), convert_choice_lists(), dawg_permute(), improve_by_chopping(), insert_seam(), number_permute(), number_permute_and_select(), permute_all(), permute_compound_words(), permute_subword(), permute_top_choice(), permute_words(), rebuild_current_state(), test_insert_seam(), UniformCertainties(), and word_associator().

#define array_free   memfree

Free the memory allocated to this array.

Definition at line 82 of file tessarray.h.

Referenced by delete_seam_pile(), evaluate_chunks(), evaluate_state(), and free_seam_list().

#define array_index ( a,
 )     ((i<array_count(a)) ? (a)->base[i] : 0)

Check to make sure that the index value is valid. Return the value of the nth element currently in the array.

Definition at line 89 of file tessarray.h.

Referenced by dawg_permute(), number_permute(), and UniformCertainties().

#define array_limit (  )     ((a)->limit)

Return the maximum number of elements that could be currently held in this array without further expansion.

Definition at line 96 of file tessarray.h.

Referenced by array_new(), and array_push().

#define array_loop ( a,
 )     for (x=0; x < array_count (a); x++)

Iterate through each of the array elements. Each value can then be accessed by: array_index (a, x)

Definition at line 103 of file tessarray.h.

Referenced by combine_seam(), delete_seam_pile(), free_seam_list(), permute_compound_words(), permute_top_choice(), and print_seams().

#define array_top (  )     ((a)->base[array_count (a) - 1])

Return the last element that was pushed on this array.

Definition at line 109 of file tessarray.h.

Referenced by array_push().

#define array_value ( a,
 )     ((a)->base[i])

Return the nth element of the array. Don't do range checking.

Definition at line 115 of file tessarray.h.

Referenced by any_shared_split_points(), array_insert(), array_new(), break_pieces(), combine_seam(), convert_choice_lists(), delete_seam_pile(), free_seam_list(), improve_one_blob(), insert_seam(), join_pieces(), permute_compound_words(), permute_subword(), permute_top_choice(), print_seams(), rebuild_current_state(), select_blob_to_split(), and test_insert_seam().

#define DEFAULT_SIZE   2

bytes allocated by default, see array_new()

Definition at line 71 of file tessarray.h.

Referenced by array_new().


Typedef Documentation

ARRAY

Pointer to array_record, one entry in dynamic array of strings.

typedef int(*) intProc()

Definition at line 62 of file tessarray.h.

typedef void(*) voidProc()

Definition at line 60 of file tessarray.h.


Function Documentation

ARRAY array_insert ( ARRAY  array,
int  index,
void *  value 
)

Insert a data element into a particular spot in the array.

Move all the elements in the array (past that spot) down one to make room for the new element.

Definition at line 42 of file tessarray.cpp.

References array_count, array_push(), array_value, and NULL.

Referenced by improve_one_blob(), and insert_seam().

00042                                                         { 
00043   int x;
00044 
00045   array = array_push (array, NULL);
00046   for (x = array_count (array) - 1; x > index; x--)
00047     array_value (array, x) = array_value (array, x - 1);
00048   array_value (array, index) = value;
00049   return (array);
00050 }

ARRAY array_new ( int  num  ) 

Create a new array with a certain number of elements.

If the number of elements requested is 0 then the default number will be used.

Definition at line 58 of file tessarray.cpp.

References array_count, array_limit, array_value, cprintf(), DEFAULT_SIZE, and memalloc().

Referenced by new_seam_list().

00058                          { 
00059   ARRAY temp;
00060   int x;
00061 
00062   if (num == 0)
00063     num = DEFAULT_SIZE;
00064   temp = (ARRAY) memalloc ((num - 2) * sizeof (char *) +
00065     sizeof (struct array_record));
00066   if (!temp) {
00067     cprintf ("error: Out of memory in array_new\n");
00068     exit (1);                    //?err_exit ();
00069   }
00070   array_count (temp) = 0;
00071   array_limit (temp) = num;
00072   for (x = 0; x < num; x++)
00073     array_value (temp, x) = (char *) 0;
00074   return (temp);
00075 }

ARRAY array_push ( ARRAY  array,
void *  value 
)

Add a new element onto the top of the array.

If there is no more room, room is made by "realloc"ing the array. This means that the new array location may change. All previous references to its old location may no longer be valid.

Definition at line 85 of file tessarray.cpp.

References array_count, array_limit, array_top, cprintf(), and memrealloc().

Referenced by add_seam(), array_insert(), choose_best_seam(), chop_word_main(), evaluate_chunks(), permute_subword(), and rebuild_current_state().

00085                                            { 
00086   if (array_count (array) == array_limit (array)) {
00087     array = (ARRAY) memrealloc (array, (array_limit (array) * 2 - 2) *
00088       sizeof (char *) +
00089       sizeof (struct array_record),
00090       (array_limit (array) -
00091       2) * sizeof (char *) +
00092       sizeof (struct array_record));
00093     if (!array) {
00094       cprintf ("error: Out of memory in array_push\n");
00095       exit (1);                  //?err_exit ();
00096     }
00097     array_limit (array) *= 2;
00098   }
00099   array_count (array)++;
00100   array_top (array) = value;
00101   return (array);
00102 }


Generated on Wed Feb 28 19:49:22 2007 for Tesseract by  doxygen 1.5.1