Leptonica  1.83.1
Image processing and image analysis suite
dnahash.c File Reference
#include "allheaders.h"
#include "array_internal.h"

Go to the source code of this file.

Functions

L_DNAHASHl_dnaHashCreate (l_int32 nbuckets, l_int32 initsize)
 
void l_dnaHashDestroy (L_DNAHASH **pdahash)
 
L_DNAl_dnaHashGetDna (L_DNAHASH *dahash, l_uint64 key, l_int32 copyflag)
 
l_ok l_dnaHashAdd (L_DNAHASH *dahash, l_uint64 key, l_float64 value)
 

Detailed Description

     Dnahash creation, destruction
         L_DNAHASH   *l_dnaHashCreate()
         void         l_dnaHashDestroy()

     Dnahash accessor and modifier
         L_DNA       *l_dnaHashGetDna()
         l_int32      l_dnaHashAdd()

   (1) The DnaHash is an array of Dna.  It is a simple method used for
       fast lookup of templates in the jbig2 classifier (jbclass.c).

Definition in file dnahash.c.

Function Documentation

◆ l_dnaHashAdd()

l_ok l_dnaHashAdd ( L_DNAHASH dahash,
l_uint64  key,
l_float64  value 
)

l_dnaHashAdd()

Parameters
[in]dahash
[in]keykey to be hashed into a bucket number
[in]valuefloat value to be appended to the specific dna
Returns
0 if OK; 1 on error

Definition at line 170 of file dnahash.c.

References L_DnaHash::dna, L_DnaHash::initsize, l_dnaAddNumber(), and l_dnaCreate().

◆ l_dnaHashCreate()

L_DNAHASH* l_dnaHashCreate ( l_int32  nbuckets,
l_int32  initsize 
)

l_dnaHashCreate()

Parameters
[in]nbucketsthe number of buckets in the hash table, which should be prime.
[in]initsizeinitial size of each allocated dna; 0 for default
Returns
ptr to new dnahash, or NULL on error
Notes:
     (1) If nbuckets is not prime, use the next largest prime.
     (2) In use, stored dna are created by l_dnaHashAdd().

Definition at line 69 of file dnahash.c.

References L_DnaHash::dna, findNextLargerPrime(), L_DnaHash::initsize, and lept_isPrime().

◆ l_dnaHashDestroy()

void l_dnaHashDestroy ( L_DNAHASH **  pdahash)

l_dnaHashDestroy()

Parameters
[in,out]pdahashwill be set to null before returning
Returns
void

Definition at line 104 of file dnahash.c.

References L_DnaHash::dna, and l_dnaDestroy().

◆ l_dnaHashGetDna()

L_DNA* l_dnaHashGetDna ( L_DNAHASH dahash,
l_uint64  key,
l_int32  copyflag 
)

l_dnaHashGetDna()

Parameters
[in]dahash
[in]keykey to be hashed into a bucket number
[in]copyflagL_NOCOPY, L_COPY, L_CLONE
Returns
ptr to dna

Definition at line 137 of file dnahash.c.

References L_DnaHash::dna, L_COPY, l_dnaClone(), l_dnaCopy(), and L_NOCOPY.