offbrand
A collection of generic, reference counted datastructures in C for C
 All Classes Files Functions Variables Typedefs Macros Groups
Classes | Typedefs | Functions | Variables
obmap_private.h File Reference

obmap Private Interface More...

#include "../obmap.h"
#include "../obvector.h"
#include "../obdeque.h"

Go to the source code of this file.

Classes

struct  obmap_pair_struct
 obmap pair internal structure, encapsulates a key-value pair for the given map More...
 
struct  obmap_struct
 obmap internal structure, encapsulating all data needed for an instance of obmap More...
 

Typedefs

typedef struct obmap_pair_struct obmap_pair
 obmap pair internal structure, encapsulates a key-value pair for the given map
 

Functions

obmap_pairobmap_new_pair (obj *key, obj *value)
 Default constructor for an obmap_pair. More...
 
obmap_pairobmap_copy_pair (obmap_pair *mp)
 Copy constructor, creates a new obmap_pair with the same key-value of an existing obmap_pair. More...
 
void obmap_replace_pair_value (obmap_pair *mp, obj *value)
 Replaces existing value in an obmap_pair with the supplied value. More...
 
ob_hash_t obmap_hash_pair (const obj *to_hash)
 Hash function for obmap_pair. More...
 
void obmap_display_pair (const obj *to_print)
 Displays an instance of obmap_pair to stderr. More...
 
void obmap_destroy_pair (obj *to_dealloc)
 Destructor for obmap_pair. More...
 
obmapobmap_create_default (void)
 Default constructor for obmap. More...
 
ob_hash_t obmap_hash (const obj *to_hash)
 Hash function for obmap. More...
 
int8_t obmap_compare (const obj *a, const obj *b)
 Compares two instances of obmap. More...
 
void obmap_display (const obj *to_print)
 Displays an instance of obmap to stderr. More...
 
void obmap_destroy (obj *to_dealloc)
 Destructor for obmap. More...
 
void obmap_increase_size (obmap *to_size)
 Increases the size of the map to the next capacity within MAP_CAPACITIES array. More...
 
void obmap_add_to_table (obmap *m, obdeque_iterator *it)
 Adds an obdeque_iterator to the proper location within the obmap. More...
 
ob_hash_t obmap_find_key (const obmap *m, const obj *key)
 Finds a key within the hash table, it exists. More...
 
ob_hash_t obmap_offset_collision (ob_hash_t prev_offset)
 Generates an offset from the hash value to rectify collisions. More...
 

Variables

const uint32_t MAP_CAPACITIES []
 
const uint32_t NUM_CAPACITIES
 
const double MAX_LOAD_FACTOR
 

Detailed Description

obmap Private Interface

Author
theck

Function Documentation

void obmap_add_to_table ( obmap m,
obdeque_iterator it 
)

Adds an obdeque_iterator to the proper location within the obmap.

Parameters
mThe obmap to add the iterator to
itThe obdeque_iterator to add to the hash table
int8_t obmap_compare ( const obj a,
const obj b 
)

Compares two instances of obmap.

Parameters
aA non-NULL obj pointer to type obmap
bA non-NULL obj pointer to type obmap
Return values
OB_LESS_THANobj a is less than b
OB_GREATER_THANobj a is equivalent to b
OB_EQUAL_TOobj a is greater than b
obmap_pair* obmap_copy_pair ( obmap_pair mp)

Copy constructor, creates a new obmap_pair with the same key-value of an existing obmap_pair.

Parameters
mpThe obmap instance to copy
Returns
An instance of class obmap_pair that contains the same key-value as mp
obmap* obmap_create_default ( void  )

Default constructor for obmap.

Returns
An instance of class obmap
Warning
All public constructors should call this constructor and intialize individual members as needed, so that all base data is initialized properly.
void obmap_destroy ( obj to_dealloc)

Destructor for obmap.

Parameters
to_deallocAn obj pointer to an instance of obmap with reference count of 0
Warning
Do not call manually, release will call automatically when the instances reference count drops to 0!
void obmap_destroy_pair ( obj to_dealloc)

Destructor for obmap_pair.

Parameters
to_deallocAn obj pointer to an instance of obmap with reference count of 0
Warning
Do not call manually, release will call automatically when the instances reference count drops to 0!
void obmap_display ( const obj to_print)

Displays an instance of obmap to stderr.

Parameters
to_printA non-NULL obj pointer to type obmap
void obmap_display_pair ( const obj to_print)

Displays an instance of obmap_pair to stderr.

Parameters
to_printA non-NULL obj pointer to type obmap_pair
ob_hash_t obmap_find_key ( const obmap m,
const obj key 
)

Finds a key within the hash table, it exists.

Parameters
mThe obmap in which to search for the key
keyThe key to serach for within the obmap
Returns
Index in the hash_table where a result can be found or where a NULL value resides if key was not found
ob_hash_t obmap_hash ( const obj to_hash)

Hash function for obmap.

Parameters
to_hashAn obj pointer to an instance of obmap
Returns
Key value (hash) for the given obj pointer to a obmap
ob_hash_t obmap_hash_pair ( const obj to_hash)

Hash function for obmap_pair.

Parameters
to_hashAn obj pointer to an instance of obmap_pair
Returns
Key value (hash) for the given obj pointer to a obmap_pair
void obmap_increase_size ( obmap to_size)

Increases the size of the map to the next capacity within MAP_CAPACITIES array.

Parameters
to_sizeobmap to resize
obmap_pair* obmap_new_pair ( obj key,
obj value 
)

Default constructor for an obmap_pair.

Parameters
keyOffbrand compatible class instance used to lookup value within hash table
valueOffbrand compatible class stored within the obmap at a position denoted by key
Returns
An instance of class obmap_pair
Warning
All public constructors should call this constructor and intialize individual members as needed, so that all base data is initialized properly.
ob_hash_t obmap_offset_collision ( ob_hash_t  prev_offset)

Generates an offset from the hash value to rectify collisions.

Parameters
prev_offsetLast offset provided (0 if initiating call for the first time)
Returns
New offset to the next possible location to insert within table
void obmap_replace_pair_value ( obmap_pair mp,
obj value 
)

Replaces existing value in an obmap_pair with the supplied value.

Parameters
mpAn instance of obmap_pair
valueThe new value to replace the existing value

Variable Documentation

const uint32_t MAP_CAPACITIES[]

Map capacity table, where capacities are the nearest prime numbers less than powers of 2.

const double MAX_LOAD_FACTOR

Maximum load factor of an obmap before the map will be resized.

const uint32_t NUM_CAPACITIES

Number of elements in the map capacity table.