GCC Middle and Back End API Reference
|
#include <pointer-set.h>
Public Member Functions | |
pointer_map () | |
~pointer_map () | |
T * | contains (const void *p) |
T * | insert (const void *p, bool *existed_p=NULL) |
void | traverse (bool(*fn)(const void *, T *, void *), void *data) |
Protected Attributes | |
size_t | log_slots |
size_t | n_slots |
size_t | n_elements |
const void ** | slots |
Private Attributes | |
T * | values |
A pointer map is represented the same way as a pointer_set, so the hash code is based on the address of the key, rather than its contents. Null keys are a reserved value. Deletion is not supported (yet). There is no mechanism for user control of hash function, equality comparison, initial size, or resizing policy.
pointer_map< T >::pointer_map | ( | void | ) |
Allocate an empty pointer map.
pointer_map< T >::~pointer_map | ( | void | ) |
Reclaims all memory associated with PMAP.
References NULL, and pointer_set_lookup().
T * pointer_map< T >::contains | ( | const void * | p | ) |
Returns a pointer to the value to which P maps, if PMAP contains P. P must be nonnull. Return NULL if PMAP does not contain P.
Collisions are resolved by linear probing.
Referenced by streamer_tree_cache_append().
T * pointer_map< T >::insert | ( | const void * | p, |
bool * | existed_p = NULL |
||
) |
Inserts P into PMAP if it wasn't already there. Returns a pointer to the value. P must be nonnull.
For simplicity, expand the map even if P is already there. This can be superfluous but can happen at most once.
??? Fugly that we have to inline that here.
References pointer_set_lookup(), slots, and T.
void pointer_map< T >::traverse | ( | bool(*)(const void *, T *, void *) | fn, |
void * | data | ||
) |
Pass each pointer in PMAP to the function in FN, together with the pointer to the value and the fixed parameter DATA. If FN returns false, the iteration stops.
|
inherited |
Referenced by pointer_map_contains(), and pointer_set_insert().
|
inherited |
Referenced by pointer_map_contains(), and pointer_set_contains().
|
inherited |
Referenced by pointer_map_contains(), pointer_set_contains(), pointer_set_insert(), and pointer_set_lookup().
|
inherited |
Referenced by pointer_map_contains(), pointer_set_insert(), and pointer_set_lookup().
|
private |