transfered from codeberg
This commit is contained in:
20
source_code/external_code/hash_map/LICENSE
Normal file
20
source_code/external_code/hash_map/LICENSE
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 Joshua J Baker
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
10
source_code/external_code/hash_map/addendum.txt
Normal file
10
source_code/external_code/hash_map/addendum.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
I have renamed the static functions
|
||||
|
||||
__malloc
|
||||
__remalloc
|
||||
|
||||
and
|
||||
|
||||
__free
|
||||
|
||||
in the .c file, in order to respect the C standard and hopefully get it working on openBSD
|
||||
1154
source_code/external_code/hash_map/hashmap.c
Normal file
1154
source_code/external_code/hash_map/hashmap.c
Normal file
File diff suppressed because it is too large
Load Diff
62
source_code/external_code/hash_map/hashmap.h
Normal file
62
source_code/external_code/hash_map/hashmap.h
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright 2020 Joshua J Baker. All rights reserved.
|
||||
// Use of this source code is governed by an MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
#ifndef HASHMAP_H
|
||||
#define HASHMAP_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
struct hashmap;
|
||||
|
||||
struct hashmap *hashmap_new(size_t elsize, size_t cap, uint64_t seed0,
|
||||
uint64_t seed1,
|
||||
uint64_t (*hash)(const void *item, uint64_t seed0, uint64_t seed1),
|
||||
int (*compare)(const void *a, const void *b, void *udata),
|
||||
void (*elfree)(void *item),
|
||||
void *udata);
|
||||
|
||||
struct hashmap *hashmap_new_with_allocator(void *(*malloc)(size_t),
|
||||
void *(*realloc)(void *, size_t), void (*free)(void*), size_t elsize,
|
||||
size_t cap, uint64_t seed0, uint64_t seed1,
|
||||
uint64_t (*hash)(const void *item, uint64_t seed0, uint64_t seed1),
|
||||
int (*compare)(const void *a, const void *b, void *udata),
|
||||
void (*elfree)(void *item),
|
||||
void *udata);
|
||||
|
||||
void hashmap_free(struct hashmap *map);
|
||||
void hashmap_clear(struct hashmap *map, bool update_cap);
|
||||
size_t hashmap_count(const struct hashmap *map);
|
||||
bool hashmap_oom(struct hashmap *map);
|
||||
const void *hashmap_get(const struct hashmap *map, const void *item);
|
||||
const void *hashmap_set(struct hashmap *map, const void *item);
|
||||
const void *hashmap_delete(struct hashmap *map, const void *item);
|
||||
const void *hashmap_probe(struct hashmap *map, uint64_t position);
|
||||
bool hashmap_scan(struct hashmap *map, bool (*iter)(const void *item, void *udata), void *udata);
|
||||
bool hashmap_iter(struct hashmap *map, size_t *i, void **item);
|
||||
|
||||
uint64_t hashmap_sip(const void *data, size_t len, uint64_t seed0, uint64_t seed1);
|
||||
uint64_t hashmap_murmur(const void *data, size_t len, uint64_t seed0, uint64_t seed1);
|
||||
uint64_t hashmap_xxhash3(const void *data, size_t len, uint64_t seed0, uint64_t seed1);
|
||||
|
||||
const void *hashmap_get_with_hash(const struct hashmap *map, const void *key, uint64_t hash);
|
||||
const void *hashmap_delete_with_hash(struct hashmap *map, const void *key, uint64_t hash);
|
||||
const void *hashmap_set_with_hash(struct hashmap *map, const void *item, uint64_t hash);
|
||||
void hashmap_set_grow_by_power(struct hashmap *map, size_t power);
|
||||
void hashmap_set_load_factor(struct hashmap *map, double load_factor);
|
||||
|
||||
|
||||
// DEPRECATED: use `hashmap_new_with_allocator`
|
||||
void hashmap_set_allocator(void *(*malloc)(size_t), void (*free)(void*));
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // HASHMAP_H
|
||||
Reference in New Issue
Block a user