Tesseract 3.01
/data/source/tesseract-ocr/wordrec/tally.h
Go to the documentation of this file.
00001 /* -*-C-*-
00002  ********************************************************************************
00003  *
00004  * File:        tally.h  (Formerly tally.h)
00005  * Description:
00006  * Author:       Mark Seaman, SW Productivity
00007  * Created:      Fri Oct 16 14:37:00 1987
00008  * Modified:     Wed Apr 10 10:45:41 1991 (Mark Seaman) marks@hpgrlt
00009  * Language:     C
00010  * Package:      N/A
00011  * Status:       Reusable Software Component
00012  *
00013  * (c) Copyright 1987, Hewlett-Packard Company.
00014  ** Licensed under the Apache License, Version 2.0 (the "License");
00015  ** you may not use this file except in compliance with the License.
00016  ** You may obtain a copy of the License at
00017  ** http://www.apache.org/licenses/LICENSE-2.0
00018  ** Unless required by applicable law or agreed to in writing, software
00019  ** distributed under the License is distributed on an "AS IS" BASIS,
00020  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00021  ** See the License for the specific language governing permissions and
00022  ** limitations under the License.
00023  *
00024  *********************************************************************************/
00025 #ifndef TALLY_H
00026 #define TALLY_H
00027 
00028 /*----------------------------------------------------------------------
00029               I n c l u d e s
00030 ----------------------------------------------------------------------*/
00031 #include <stdio.h>
00032 
00033 /*----------------------------------------------------------------------
00034               T y p e s
00035 ----------------------------------------------------------------------*/
00036 typedef struct _TALLY_
00037 {
00038   int count;
00039   int num_buckets;
00040   int buckets[1];
00041 } *TALLY;
00042 
00043 /*----------------------------------------------------------------------
00044               M a c r o s
00045 ----------------------------------------------------------------------*/
00046 /**********************************************************************
00047  * inc_tally_bucket
00048  *
00049  * Increment the bucket count for the chosen bucket.
00050  **********************************************************************/
00051 
00052 #define inc_tally_bucket(t,i) \
00053 (t->count++,                \
00054         ((i < t->num_buckets) ?    \
00055         (t->buckets[i]++) :       \
00056         (t->buckets[t->num_buckets-1]++)))
00057 
00058 /**********************************************************************
00059  * iterate_tally
00060  *
00061  * Iterate through all the buckets in a tally record.
00062  **********************************************************************/
00063 
00064 #define iterate_tally(t,i)  \
00065 for (i=0; i<t->num_buckets; i++)
00066 
00067 /**********************************************************************
00068  * tally_entry
00069  *
00070  * Access one of the buckets of a tally record without bounds checking.
00071  **********************************************************************/
00072 
00073 #define tally_entry(t,i)            \
00074 (t->buckets[i])
00075 
00076 /**********************************************************************
00077  * tally_value
00078  *
00079  * Access one of the buckets of a tally record with bounds checking.
00080  **********************************************************************
00081 
00082 #define tally_value(t,i)            \
00083 ((i>=0 && i<t->num_buckets) ?     \
00084   (tally_entry (t,i))   :          \
00085   (cprintf ("error: tried to access non-existant bucket %d\n", i)))
00086 */
00087 
00088 /*----------------------------------------------------------------------
00089               F u n c t i o n s
00090 ----------------------------------------------------------------------*/
00091 TALLY new_tally(int num_buckets); 
00092 
00093 void print_tally(FILE *file, const char *string, TALLY t); 
00094 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines