wordrec/tally.cpp

Go to the documentation of this file.
00001 
00020 /*----------------------------------------------------------------------
00021               I n c l u d e s
00022 ----------------------------------------------------------------------*/
00023 #include "tally.h"
00024 #include "freelist.h"
00025 #include "callcpp.h"
00026 
00027 /*----------------------------------------------------------------------
00028               F u n c t i o n s
00029 ----------------------------------------------------------------------*/
00030 /* ================== */
00034 TALLY new_tally(int num_buckets) { 
00035   TALLY t;
00036   int x;
00037 
00038   t = (TALLY) memalloc ((num_buckets + 2) * sizeof (int));
00039   t->count = 0;
00040   t->num_buckets = num_buckets;
00041 
00042   iterate_tally (t, x) tally_entry (t, x) = 0;
00043 
00044   return (t);
00045 }
00046 
00047 
00048 /* ================== */
00052 void print_tally(FILE *file, const char *string, TALLY t) { 
00053   int x;
00054 
00055   cprintf ("%d %s buckets\n", t->num_buckets, string);
00056   cprintf ("%d samples in %s\n", t->count, string);
00057 
00058   iterate_tally (t, x)
00059     cprintf ("   %s [%d] = %d\n", string, x, tally_entry (t, x));
00060   cprintf ("\n");
00061 }

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