Implements a map of ParameterMapElement instances.
Implementation is done via an array. Via the call finalize_map(), it is sorted. Then, get() may be called. If it is called before, an error is thrown.
In finalize_map() the array is sorted. So inserting n elements is n*O(1) + O(n*log n) = O(n*log n). Getting an element is then possible in O(log n) by binary search
Definition at line 130 of file ParameterMap.h.
Public Member Functions | |
ParameterMap () | |
virtual | ~ParameterMap () |
void | put (SGParamInfo *key, SGParamInfo *value) |
SGParamInfo * | get (SGParamInfo *key) const |
void | finalize_map () |
void | print_map () |
Protected Attributes | |
DynArray< ParameterMapElement * > | m_map_elements |
bool | m_finalized |
ParameterMap | ( | ) |
constructor
Definition at line 130 of file ParameterMap.cpp.
~ParameterMap | ( | ) | [virtual] |
destructor
Definition at line 140 of file ParameterMap.cpp.
void finalize_map | ( | ) |
Finalizes the map. Has to be called before get may be called if more than one element in map
Definition at line 179 of file ParameterMap.cpp.
SGParamInfo * get | ( | SGParamInfo * | key | ) | const |
Gets a specific element of the map. Note that it is SG_REF'ed finalize_map() has to be called first if more than one elements are in map
key | key of the element to get |
Definition at line 152 of file ParameterMap.cpp.
void print_map | ( | ) |
prints all elements of this map
Definition at line 190 of file ParameterMap.cpp.
void put | ( | SGParamInfo * | key, | |
SGParamInfo * | value | |||
) |
Puts an newly allocated element into the map
key | key of the element | |
value | value of the lement |
Definition at line 146 of file ParameterMap.cpp.
bool m_finalized [protected] |
variable that indicates if underlying array is sorted (and thus get may safely be called)
Definition at line 171 of file ParameterMap.h.
DynArray<ParameterMapElement*> m_map_elements [protected] |
list of CLinearMap elements, this is always kept sorted
Definition at line 167 of file ParameterMap.h.