cutil/bitvec.h

Go to the documentation of this file.
00001 
00019 #ifndef   BITVEC_H
00020 #define   BITVEC_H
00021 
00022 /* =================
00023           Include Files and Type Defines
00024  ==================== */
00025 #define BITSINLONG      32       /* no of bits in a long */
00026 
00031 typedef unsigned int *BIT_VECTOR;
00032 
00033 /* =================
00034           Public Function Prototypes
00035  ==================== */
00036 #define zero_all_bits(array,length) \
00037 {\
00038    register int         index;                  /*temporary index*/\
00039 \
00040 for (index=0;index<length;index++)\
00041    array[index]=0;                              /*zero all bits*/\
00042 }
00043 
00044 #define set_all_bits(array,length) \
00045 {\
00046    register int         index;                  /*temporary index*/\
00047 \
00048 for (index=0;index<length;index++)\
00049    array[index]= ~0;                         /*set all bits*/\
00050 }
00051 
00052 #define copy_all_bits(source,dest,length) \
00053 {\
00054    register int         index;                  /*temporary index*/\
00055 \
00056 for (index=0;index<length;index++)\
00057    dest[index]=source[index];                   /*copy all bits*/\
00058 }
00059 
00060 #define SET_BIT(array,bit) (array[bit/BITSINLONG]|=1<<(bit&(BITSINLONG-1)))
00061 
00062 #define reset_bit(array,bit) (array[bit/BITSINLONG]&=~(1<<(bit&(BITSINLONG-1))))
00063 
00064 #define test_bit(array,bit) (array[bit/BITSINLONG] & (1<<(bit&(BITSINLONG-1))))
00065 
00066 #define WordsInVectorOfSize(NumBits) \
00067 (((NumBits) + BITSINLONG - 1) / BITSINLONG)
00068 
00069 /*--------------------------------------------------------------------------
00070         Public Function Prototypes
00071 --------------------------------------------------------------------------*/
00072 BIT_VECTOR ExpandBitVector(BIT_VECTOR Vector, int NewNumBits);
00073 
00074 void FreeBitVector(BIT_VECTOR BitVector);
00075 
00076 int hamming_distance(register unsigned long *array1,
00077                      register unsigned long *array2,
00078                      register int length);
00079 
00080 BIT_VECTOR NewBitVector(int NumBits);
00081 /*
00082 #if defined(__STDC__) || defined(__cplusplus)
00083 # define _ARGS(s) s
00084 #else
00085 # define _ARGS(s) ()
00086 #endif*/
00087 
00088 /* bitvec.c
00089 BIT_VECTOR ExpandBitVector
00090   _ARGS((BIT_VECTOR Vector,
00091   int NewNumBits));
00092 
00093 void FreeBitVector
00094   _ARGS((BIT_VECTOR BitVector));
00095 
00096 int hamming_distance
00097   _ARGS((unsigned long *array1,
00098   unsigned long *array2,
00099   int length));
00100 
00101 BIT_VECTOR NewBitVector
00102   _ARGS((int NumBits));
00103 
00104 #undef _ARGS
00105 */
00106 #endif

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