Usurp public hash table interface into hash.c . The module is

created for a single purpose: A poor-man's replacement for a
  hash-set used in deriving coarse-grid connections from fine-scale
  connectivity.
This commit is contained in:
Bård Skaflestad
2010-08-27 07:37:49 +00:00
parent ecb9f57632
commit ae8742b692
2 changed files with 19 additions and 37 deletions

36
hash.c
View File

@@ -5,11 +5,13 @@
#include <stdlib.h>
#include <string.h>
#include "hash.h"
#define GOLDEN_RAT (0.6180339887498949) /* (sqrt(5) - 1) / 2 */
#define IS_POW2(x) (((x) & ((x) - 1)) == 0)
struct hash_table {
size_t m;
int *a;
};
/* ---------------------------------------------------------------------- */
static size_t
@@ -120,7 +122,20 @@ hash_table_expand(size_t m, struct hash_table *t)
/* ---------------------------------------------------------------------- */
struct hash_table *
static void
hash_table_deallocate(struct hash_table *t)
/* ---------------------------------------------------------------------- */
{
if (t != NULL) {
free(t->a);
}
free(t);
}
/* ---------------------------------------------------------------------- */
static struct hash_table *
hash_table_allocate(int m)
/* ---------------------------------------------------------------------- */
{
@@ -147,20 +162,7 @@ hash_table_allocate(int m)
/* ---------------------------------------------------------------------- */
void
hash_table_deallocate(struct hash_table *t)
/* ---------------------------------------------------------------------- */
{
if (t != NULL) {
free(t->a);
}
free(t);
}
/* ---------------------------------------------------------------------- */
int
static int
hash_table_insert(int k, struct hash_table *t)
/* ---------------------------------------------------------------------- */
{

20
hash.h
View File

@@ -1,20 +0,0 @@
#ifndef HASH_H_INCLUDED
#define HASH_H_INCLUDED
#include <stddef.h>
struct hash_table {
size_t m;
int *a;
};
struct hash_table *
hash_table_allocate(int m);
void
hash_table_deallocate(struct hash_table *t);
int
hash_table_insert(int k, struct hash_table *t);
#endif /* HASH_H_INCLUDED */