#include "bitvec.h"
#include "emalloc.h"
#include "freelist.h"
#include "callcpp.h"
#include <stdio.h>
Go to the source code of this file.
BIT_VECTOR ExpandBitVector | ( | BIT_VECTOR | Vector, | |
int | NewNumBits | |||
) |
Uses realloc to increase the size of the specified bit vector.
Vector | Bit vector to be expanded | |
NewNumBits | New size of bit vector |
Definition at line 48 of file bitvec.cpp.
References Erealloc(), and WordsInVectorOfSize.
Referenced by AddProtoToClass().
00048 { 00049 return ((BIT_VECTOR) Erealloc (Vector, 00050 sizeof (unsigned long) * 00051 WordsInVectorOfSize (NewNumBits))); 00052 00053 } /* ExpandBitVector */
void FreeBitVector | ( | BIT_VECTOR | BitVector | ) |
Frees a bit vector & decrements the global counter that keeps track of the number of bit vectors allocated.
BitVector | Bit vector to be freed |
Definition at line 69 of file bitvec.cpp.
References BitVectorCount, cprintf(), and memfree().
Referenced by compare_tess_blobs(), EndAdaptiveClassifier(), free_adapted_class(), FreeClassFields(), and FreeTempConfig().
00069 { 00070 if (BitVector) { 00071 memfree(BitVector); 00072 BitVectorCount--; 00073 } 00074 else { 00075 cprintf ("%6d BITVECTOR elements in use\n", BitVectorCount); 00076 } 00077 00078 } /* FreeBitVector */
int hamming_distance | ( | register unsigned long * | array1, | |
register unsigned long * | array2, | |||
register int | length | |||
) |
Computes the hamming distance between two bit strings.
array1 | First array to compare | |
array2 | Second array to compare | |
length | Length of arrays |
Definition at line 90 of file bitvec.cpp.
Referenced by delete_search().
00093 { 00094 register unsigned long diff; /*bit difference */ 00095 register int dist; /*total distance */ 00096 00097 dist = 0; 00098 for (; length > 0; length--) { 00099 diff = *array1++ ^ *array2++;/*different bits */ 00100 while (diff) { 00101 diff &= diff - 1; /*lose a bit */ 00102 dist++; 00103 } 00104 } 00105 return dist; /*total distance */ 00106 }
BIT_VECTOR NewBitVector | ( | int | NumBits | ) |
Allocate and return a new bit vector large enough to hold the specified number of bits.
NumBits | Number of bits in new bit vector |
Definition at line 120 of file bitvec.cpp.
References BitVectorCount, Emalloc(), and WordsInVectorOfSize.
Referenced by AddConfigToClass(), compare_tess_blobs(), InitAdaptiveClassifier(), NewAdaptedClass(), NewTempConfig(), ReadAdaptedClass(), ReadConfigs(), ReadTempConfig(), and SetUpForFloat2Int().
00120 { 00121 BitVectorCount++; 00122 return ((BIT_VECTOR) Emalloc (sizeof (unsigned long) * 00123 WordsInVectorOfSize (NumBits))); 00124 00125 } /* NewBitVector */
int BitVectorCount = 0 [static] |
** (c) Copyright Hewlett-Packard Company, 1988. ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** http://www.apache.org/licenses/LICENSE-2.0 ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License.
Definition at line 33 of file bitvec.cpp.
Referenced by FreeBitVector(), and NewBitVector().