public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
123ad4d9a44528c953bcfc3e373e83a4668f593b blob 1383 bytes (raw)

 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
/*
 * Copyright (C) 2024 olang maintainers
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
#ifndef MAP_H
#define MAP_H

#include "arena.h"

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

#define MAP_INITIAL_CAPACITY 32

#define U32_FNV1A_PRIME 0x01000193
#define U32_FNV1A_OFFSET_BASIS 0x811c9dc5

typedef struct map map_t;
typedef struct map_bucket map_bucket_t;
typedef struct map_entry map_entry_t;

typedef struct map
{
    arena_t *arena;
    map_entry_t *entries;
    size_t capacity;
} map_t;

typedef struct map_entry
{
    char *key;
    void *value;
    uint32_t hash;
    map_entry_t *next;
} map_entry_t;

map_t *
map_new(arena_t *arena);

bool
map_put(map_t *map, char *key, void *value);

void *
map_get(map_t *map, char *key);

#endif /* MAP_H */
debug log:

solving 123ad4d ...
found 123ad4d in https://git.johnnyrichard.com/olang.git

Code repositories for project(s) associated with this public inbox

	https://git.johnnyrichard.com/olang.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox