File: BFS.h

package info (click to toggle)
xsok 1.02-23
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,864 kB
  • sloc: ansic: 3,990; makefile: 72; sh: 16
file content (36 lines) | stat: -rw-r--r-- 1,168 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>

void fatal(const char *msg, ...);
void *malloc_(size_t);



/* this is BFS.h, prototypes for generic Breadth-First-Search lib. */
struct BFS {
    size_t keylength;	/* number of bytes for the key of the data 2..4 */
    size_t datalength;	/* total number of user bytes */
    size_t ptrsize;	/* number of bytes for backptrs */
    size_t totallength;
    int hashbits;	/* has table has size 1 << hashbits */
    int level;
    unsigned char *hashtable;
    unsigned char *data;
    unsigned char *endhash;
    unsigned long ndata;
    unsigned long hashmask;	/* is equal to nr. of entries */
    unsigned long read;		/* data item to read */
    unsigned long write;	/* data item to write */
    unsigned long stop;		/* helps for level wrap */
};

void BFS_init(size_t keylength, size_t datalength, int hashbits,
	      unsigned long ndata, int backtrack);
long BFS_store(void *data);	/* store data, return entrynr */
int BFS_newlevel(void);		/* request new level */
int BFS_retrieve(void *data);
long BFS_getentry(long entrynr, void *data); /* returns predecessor */