Page 1 of 1

Module: HashMap

Posted: Fri Oct 16, 2026 9:13 pm
by Archive-Poster

Code: Select all

/*
This is a simple hashmap. It can only store integers (cells).
*/

#if defined hashmap_included
    #endinput
#endif
#define hashmap_included

#if AMXX_VERSION_NUM >= 175
 #pragma reqlib hashmap
 #if !defined AMXMODX_NOAUTOLOAD
  #pragma loadlib hashmap
 #endif
#else
 #pragma library hashmap
#endif

#define REMOVED = ((1 << 31) + 1)
#define EMPTY_SLOT (~(1 << 31))

// clears the hashmap maintaining the same capacity
native hashmap_clear();

// returns non-zero value if the map contains this key
native hashmap_contains_key(key);

// places a key/value mapping in the map; returns 1 on success
// returns 0 if you use a bad key, i.e. REMOVED or EMPTY_SLOT
native hashmap_put(key, value);

// returns the value mapped by the given key
// returns EMPTY_SLOT if the key is not in the map
native hashmap_get(key);

// removes the mapping with the given key
// if the key isn't in the map, it has no effect
native hashmap_remove(key);

// returns the number of key/value mappings in the map
native hashmap_size();

// returns the available slots in the map (it grows if necessary)
native hashmap_capacity();