summaryrefslogtreecommitdiff
path: root/include/map.h
blob: b1f2650d42d1567ab7ab7b5d423d2216afaca32e (plain)
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
/*
 * Nome: Leonardo Koosuke Azuma
 * SO: Arch Linux x86_64
 *	Compilador: gcc (GCC) 13.2.1 20230801
 */
#ifndef _MYMAP_H
#define _MYMAP_H

#include <string.h>
#include <stdint.h>

#define A

typedef struct Node{
    char *key;
    char *value;
    struct Node *next;
}node;

typedef struct Map{
    uint32_t size;
    node **head;
}string_map;

string_map init_map(uint32_t size);
/*
 * 64-bit FNV-1 hash
 * https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
 */
#define FNV_offset_basis 14695981039346656037UL
#define FNV_prime 1099511628211UL
uint32_t hash_function(char *key, uint32_t size);
void insert_map(char *key, char *value, string_map map);
node *create_node(char *key, char *value);
char *get_value(char *key, string_map map);
#endif