The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
hash_map.c File Reference

This header implements a simple hash map data structure. More...

#include <datatypes/hash_map.h>
#include <mm/dymelor.h>
#include <memory.h>
#include <limits.h>
+ Include dependency graph for hash_map.c:

Go to the source code of this file.

Macros

#define HM_INITIAL_CAPACITY   8
 
#define DIB(curr_i, hash, capacity_mo)   ((curr_i) >= ((hash) & (capacity_mo)) ? (curr_i) - ((hash) & (capacity_mo)) : (capacity_mo) + 1 + (curr_i) - ((hash) & (capacity_mo)))
 
#define SWAP_VALUES(a, b)   do{__typeof(a) _tmp = (a); (a) = (b); (b) = _tmp;}while(0)
 

Functions

static hash_t _get_hash (key_type_t key)
 
void _hash_map_init (struct _inner_hash_map_t *_i_hmap)
 
void _hash_map_fini (struct _inner_hash_map_t *_i_hmap)
 
static void _hash_map_insert_hashed (struct _inner_hash_map_t *_i_hmap, struct _hash_map_node_t node)
 
static void _hash_map_realloc_rehash (struct _inner_hash_map_t *_i_hmap, map_size_t count)
 
static void _hash_map_expand (struct _inner_hash_map_t *_i_hmap, map_size_t count)
 
static void _hash_map_shrink (struct _inner_hash_map_t *_i_hmap, map_size_t count)
 
void _hash_map_add (struct _inner_hash_map_t *_i_hmap, key_type_t key, map_size_t count)
 
static map_size_t _hash_map_index_lookup (struct _inner_hash_map_t *_i_hmap, key_type_t key)
 
unsigned _hash_map_lookup (struct _inner_hash_map_t *_i_hmap, unsigned long long key)
 
void _hash_map_update_i (struct _inner_hash_map_t *_i_hmap, unsigned long long key, map_size_t new_i)
 
void _hash_map_remove (struct _inner_hash_map_t *_i_hmap, unsigned long long key, map_size_t cur_count)
 
size_t _hash_map_dump_size (struct _inner_hash_map_t *_i_hmap)
 
unsigned char * _hash_map_dump (struct _inner_hash_map_t *_i_hmap, unsigned char *_destination)
 
unsigned char * _hash_map_load (struct _inner_hash_map_t *_i_hmap, unsigned char *_source)
 

Detailed Description

This header implements a simple hash map data structure.

Copyright (C) 2008-2018 HPDCS Group http://www.dis.uniroma1.it/~hpdcs

This file is part of ROOT-Sim (ROme OpTimistic Simulator).

ROOT-Sim 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; only version 3 of the License applies.

ROOT-Sim 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 ROOT-Sim; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Date
9 Nov 2018
Author
Andrea Piccione

This a simple hash map implementation, currently used in the abm layer. It's based on a open addressing design: it handles collisions through linear probing, entries are reordered on insertion through robin hood hashing.

Definition in file hash_map.c.