tesseract  4.00.00dev
bitvec.h File Reference
#include "host.h"

Go to the source code of this file.

Macros

#define BITSINLONG   32
 
#define zero_all_bits(array, length)
 
#define set_all_bits(array, length)
 
#define copy_all_bits(source, dest, length)
 
#define SET_BIT(array, bit)   (array[bit/BITSINLONG]|=1<<(bit&(BITSINLONG-1)))
 
#define reset_bit(array, bit)   (array[bit/BITSINLONG]&=~(1<<(bit&(BITSINLONG-1))))
 
#define test_bit(array, bit)   (array[bit/BITSINLONG] & (1<<(bit&(BITSINLONG-1))))
 
#define WordsInVectorOfSize(NumBits)   (((NumBits) + BITSINLONG - 1) / BITSINLONG)
 

Typedefs

typedef uinT32BIT_VECTOR
 

Functions

BIT_VECTOR ExpandBitVector (BIT_VECTOR Vector, int NewNumBits)
 
void FreeBitVector (BIT_VECTOR BitVector)
 
BIT_VECTOR NewBitVector (int NumBits)
 

Macro Definition Documentation

◆ BITSINLONG

#define BITSINLONG   32

no of bits in a long

Definition at line 27 of file bitvec.h.

◆ copy_all_bits

#define copy_all_bits (   source,
  dest,
  length 
)
Value:
{ \
int index; /*temporary index*/ \
\
for (index = 0; index < length; index++) \
dest[index] = source[index]; /*copy all bits*/ \
}

Definition at line 49 of file bitvec.h.

◆ reset_bit

#define reset_bit (   array,
  bit 
)    (array[bit/BITSINLONG]&=~(1<<(bit&(BITSINLONG-1))))

Definition at line 59 of file bitvec.h.

◆ set_all_bits

#define set_all_bits (   array,
  length 
)
Value:
{ \
int index; /*temporary index*/ \
\
for (index = 0; index < length; index++) \
array[index] = ~0; /*set all bits*/ \
}

Definition at line 41 of file bitvec.h.

◆ SET_BIT

#define SET_BIT (   array,
  bit 
)    (array[bit/BITSINLONG]|=1<<(bit&(BITSINLONG-1)))

Definition at line 57 of file bitvec.h.

◆ test_bit

#define test_bit (   array,
  bit 
)    (array[bit/BITSINLONG] & (1<<(bit&(BITSINLONG-1))))

Definition at line 61 of file bitvec.h.

◆ WordsInVectorOfSize

#define WordsInVectorOfSize (   NumBits)    (((NumBits) + BITSINLONG - 1) / BITSINLONG)

Definition at line 63 of file bitvec.h.

◆ zero_all_bits

#define zero_all_bits (   array,
  length 
)
Value:
{ \
int index; /*temporary index*/ \
\
for (index = 0; index < length; index++) \
array[index] = 0; /*zero all bits*/ \
}

Definition at line 33 of file bitvec.h.

Typedef Documentation

◆ BIT_VECTOR

typedef uinT32* BIT_VECTOR

Definition at line 28 of file bitvec.h.

Function Documentation

◆ ExpandBitVector()

BIT_VECTOR ExpandBitVector ( BIT_VECTOR  Vector,
int  NewNumBits 
)

This routine uses realloc to increase the size of the specified bit vector.

Globals:

  • none
Parameters
Vectorbit vector to be expanded
NewNumBitsnew size of bit vector
Returns
New expanded bit vector.
Note
Exceptions: none
History: Fri Nov 16 10:11:16 1990, DSJ, Created.

Definition at line 47 of file bitvec.cpp.

47  {
48  return ((BIT_VECTOR) Erealloc(Vector,
49  sizeof(Vector[0]) * WordsInVectorOfSize(NewNumBits)));
50 } /* ExpandBitVector */
#define WordsInVectorOfSize(NumBits)
Definition: bitvec.h:63
uinT32 * BIT_VECTOR
Definition: bitvec.h:28
void * Erealloc(void *ptr, int size)
Definition: emalloc.cpp:64

◆ FreeBitVector()

void FreeBitVector ( BIT_VECTOR  BitVector)

This routine frees a bit vector. It also decrements the global counter that keeps track of the number of bit vectors allocated. If BitVector is NULL, then the count is printed to stderr.

Globals:

  • BitVectorCount count of number of bit vectors allocated
Parameters
BitVectorbit vector to be freed
Note
Exceptions: none
History: Tue Oct 23 16:46:09 1990, DSJ, Created.

Definition at line 54 of file bitvec.cpp.

54  {
69  if (BitVector) {
70  Efree(BitVector);
71  }
72 } /* FreeBitVector */
void Efree(void *ptr)
Definition: emalloc.cpp:79

◆ NewBitVector()

BIT_VECTOR NewBitVector ( int  NumBits)

Allocate and return a new bit vector large enough to hold the specified number of bits.

Globals:

  • BitVectorCount number of bit vectors allocated
Parameters
NumBitsnumber of bits in new bit vector
Returns
New bit vector.
Note
Exceptions: none
History: Tue Oct 23 16:51:27 1990, DSJ, Created.

Definition at line 89 of file bitvec.cpp.

89  {
90  return ((BIT_VECTOR) Emalloc(sizeof(uinT32) *
91  WordsInVectorOfSize(NumBits)));
92 } /* NewBitVector */
#define WordsInVectorOfSize(NumBits)
Definition: bitvec.h:63
void * Emalloc(int Size)
Definition: emalloc.cpp:47
uinT32 * BIT_VECTOR
Definition: bitvec.h:28
uint32_t uinT32
Definition: host.h:39