All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Fields | Private Attributes | Related Functions
as_hashmap Struct Reference

Detailed Description

A hashtable based implementation of as_map.

To use the map, you can either initialize a stack allocated map, using as_hashmap_init():

as_hashmap_init(&map, 32);

Or you can create a new heap allocated map using as_hashmap_new():

When you are finished using the map, then you should release the map and associated resources, using as_hashmap_destroy():

The as_hashmap is a subtype of as_map. This allows you to alternatively use as_map functions, by typecasting as_hashmap to as_map.

The as_stringmap functions are simplified functions for using string key.

Each of the as_map functions proxy to the as_hashmap functions. So, calling as_map_destroy() is equivalent to calling as_hashmap_destroy().

Definition at line 76 of file as_hashmap.h.

#include "as_hashmap.h"

+ Inheritance diagram for as_hashmap:
+ Collaboration diagram for as_hashmap:

Data Fields

void * htable
 
- Data Fields inherited from as_map
void * data
 
struct as_map_hooks_s * hooks
 
- Data Fields inherited from as_val
cf_atomic32 count
 
bool free
 
enum as_val_t type
 

Private Attributes

as_map _
 

Related Functions

(Note that these are not member functions.)

int as_hashmap_clear (as_hashmap *map)
 
void as_hashmap_destroy (as_hashmap *map)
 
bool as_hashmap_foreach (const as_hashmap *map, as_map_foreach_callback callback, void *udata)
 
as_valas_hashmap_get (const as_hashmap *map, const as_val *key)
 
uint32_t as_hashmap_hashcode (const as_hashmap *map)
 
as_hashmapas_hashmap_init (as_hashmap *map, uint32_t buckets)
 
as_hashmapas_hashmap_new (uint32_t buckets)
 
int as_hashmap_remove (as_hashmap *map, const as_val *key)
 
int as_hashmap_set (as_hashmap *map, const as_val *key, const as_val *val)
 
uint32_t as_hashmap_size (const as_hashmap *map)
 

Friends And Related Function Documentation

int as_hashmap_clear ( as_hashmap map)
related

Remove all entries from the map.

Parameters
mapThe map.
Returns
0 on success. Otherwise an error occurred.
void as_hashmap_destroy ( as_hashmap map)
related

Free the map and associated resources.

Parameters
mapThe map to destroy.
bool as_hashmap_foreach ( const as_hashmap map,
as_map_foreach_callback  callback,
void *  udata 
)
related

Call the callback function for each entry in the map.

Parameters
mapThe map.
callbackThe function to call for each entry.
udataUser-data to be passed to the callback.
Returns
true if iteration completes fully. false if iteration was aborted.
as_val * as_hashmap_get ( const as_hashmap map,
const as_val key 
)
related

Get the value for specified key.

Parameters
mapThe map.
keyThe key.
Returns
The value for the specified key. Otherwise NULL.
uint32_t as_hashmap_hashcode ( const as_hashmap map)
related

The hash value of the map.

Parameters
mapThe map.
Returns
The hash value of the map.
as_hashmap * as_hashmap_init ( as_hashmap map,
uint32_t  buckets 
)
related

Initialize a stack allocated hashmap.

Parameters
mapThe map to initialize.
bucketsThe number of hash buckets to allocate.
Returns
On success, the initialized map. Otherwise NULL.
as_hashmap * as_hashmap_new ( uint32_t  buckets)
related

Creates a new map as a hashmap.

Parameters
bucketsThe number of hash buckets to allocate.
Returns
On success, the new map. Otherwise NULL.
int as_hashmap_remove ( as_hashmap map,
const as_val key 
)
related

Remove the entry specified by the key.

Parameters
mapThe map to remove the entry from.
keyThe key of the entry to be removed.
Returns
0 on success. Otherwise an error occurred.
int as_hashmap_set ( as_hashmap map,
const as_val key,
const as_val val 
)
related

Set the value for specified key.

Parameters
mapThe map.
keyThe key.
valThe value for the given key.
Returns
0 on success. Otherwise an error occurred.
uint32_t as_hashmap_size ( const as_hashmap map)
related

Get the number of entries in the map.

Parameters
mapThe map.
Returns
The number of entries in the map.

Field Documentation

as_map as_hashmap::_
private

as_hashmap is an as_map. You can cast as_hashmap to as_map.

Definition at line 83 of file as_hashmap.h.

void* as_hashmap::htable

Hashtable

Definition at line 88 of file as_hashmap.h.


The documentation for this struct was generated from the following file: