view src/ploki/hash.h @ 11562:6b0304dcec5c draft

<oerjan> ` cd bin; cp welcome \xd0\xb4\xd0\xbe\xd0\xb1\xd1\x80\xd0\xbe-\xd0\xbf\xd0\xbe\xd0\xb6\xd0\xb0\xd0\xbb\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd1\x8c; sled \xd0\xb4\xd0\xbe\xd0\xb1\xd1\x80\xd0\xbe-\xd0\xbf\xd0\xbe\xd0\xb6\xd0\xb0\xd0\xbb\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd1\x8c//s,welcome,welcome.ru,
author HackEso <hackeso@esolangs.org>
date Wed, 16 May 2018 04:46:17 +0100
parents ac0403686959
children
line wrap: on
line source

#ifndef HASH_H_
#define HASH_H_

#include <stddef.h>

typedef struct {
	size_t entries, size, newsize;
	size_t brk;
	size_t seed;
	size_t iter;
	struct h_node *iterptr;
	struct h_node **table;
	size_t (*hash)(const void *, size_t);
	int (*cmp)(const void *, const void *);
	void (*delk)(void *);
	void (*delv)(void *);
} Hash;

enum {
	H_OK,
	H_EXIST,
	H_NOENT
};

void h_init(
		Hash *,
		size_t (*)(const void *, size_t),
		int (*)(const void *, const void *),
		void (*)(void *),
		void (*)(void *)
		);
void h_end(Hash *);
int h_get(Hash *, const void *, void **);
int h_del(Hash *, const void *);
#if 0
void h_push(Hash *, void *, void *);
#endif
int h_put(Hash *, void *, void *, int);
void h_reset(Hash *);
int h_nextkv(Hash *, void **, void **);

#if 0
size_t h_entries(const Hash *);
#define h_entries(h) ((h)->entries + 0)
#endif

#endif /* HASH_H_ */