GCC Middle and Back End API Reference
pointer_map< T > Class Template Reference

#include <pointer-set.h>

Inheritance diagram for pointer_map< T >:
Collaboration diagram for pointer_map< T >:

Public Member Functions

 pointer_map ()
 ~pointer_map ()
Tcontains (const void *p)
Tinsert (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


Detailed Description

template<typename T>
class pointer_map< T >

   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.  

Constructor & Destructor Documentation

template<typename T >
pointer_map< T >::pointer_map ( void  )
   Allocate an empty pointer map.  
template<typename T >
pointer_map< T >::~pointer_map ( void  )
   Reclaims all memory associated with PMAP.  

References pointer_set_lookup().

Member Function Documentation

template<typename T >
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().

template<typename T >
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.

template<class 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.  

Field Documentation

size_t pointer_set_t::log_slots
size_t pointer_set_t::n_elements
size_t pointer_set_t::n_slots
const void** pointer_set_t::slots
template<typename T>
T* pointer_map< T >::values

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