src/common/map.c
// Use the robin hood hashing method to probe the map for a sutable location to
// place the provided entry
Use the robin hood hashing method to probe the map for a sutable location to
place the provided entry
Use the robin hood hashing method to probe the map for a sutable location to place the provided entry
static enum natwm_error map_probe(struct map *map, struct map_entry *entry, uint32_t initial_index)
{
        uint32_t probe_position = initial_index;
        struct map_entry *insert_entry = entry;
        for (size_t i = 0; i < map->length; ++i) {
                if (probe_position >= map->length) {
                        probe_position = 0;
                }
                struct map_entry *current_entry = map->entries[probe_position];
                if (!is_entry_present(current_entry)) {
                        map->entries[probe_position] = insert_entry;
                        return NO_ERROR;
                }
                uint32_t insert_dib = get_dib(map, insert_entry, probe_position);
                uint32_t current_dib = get_dib(map, current_entry, probe_position);
                if (current_dib < insert_dib) {
                        map->entries[probe_position] = insert_entry;
                        insert_entry = current_entry;
                }
                probe_position += 1;
        }
        return CAPACITY_ERROR;
}
static enum natwm_error map_probe ( struct map * map , struct map_entry * entry , uint32_t initial_index ) { uint32_t probe_position = initial_index ; struct map_entry * insert_entry = entry ; for ( size_t i = 0 ; i < map -> length ; ++ i ) { if ( probe_position >= map -> length ) { probe_position = 0 ; } struct map_entry * current_entry = map -> entries [ probe_position ] ; if ( ! is_entry_present ( current_entry ) ) { map -> entries [ probe_position ] = insert_entry ; return NO_ERROR ; } uint32_t insert_dib = get_dib ( map , insert_entry , probe_position ) ; uint32_t current_dib = get_dib ( map , current_entry , probe_position ) ; if ( current_dib < insert_dib ) { map -> entries [ probe_position ] = insert_entry ; insert_entry = current_entry ; } probe_position += 1 ; } return CAPACITY_ERROR ; }
Use the robin hood hashing method to probe the map for a sutable location to
place the provided entry
Use the robin hood hashing method to probe the map for a sutable location to place the provided entry
// As we probe through the map these will continually get updated // Insert here // If the current entry has a lower dib then the entry we are // trying to insert then we swap the entries // Keep probing