SHOGUN
v2.0.0
|
Implements a map of ParameterMapElement instances Maps one key to a set of values.
Implementation is done via an array. Via the call finalize_map(), a hidden structure is built which bundles all values for each key. Then, get() may be called, which returns an array of values for a key. If it is called before, an error is thrown.
Putting elements is in O(1). finalize_map sorts the underlying array and then regroups values, O(n*log n). Add all values and then call once. Getting a set of values is possible in O(log n) via binary search
Definition at line 161 of file ParameterMap.h.
Public Member Functions | |
ParameterMap () | |
virtual | ~ParameterMap () |
void | put (const SGParamInfo *key, const SGParamInfo *value) |
DynArray< const SGParamInfo * > * | get (const SGParamInfo) const |
DynArray< const SGParamInfo * > * | get (const SGParamInfo *key) const |
void | finalize_map () |
void | print_map () |
Protected Attributes | |
DynArray< ParameterMapElement * > | m_map_elements |
DynArray< ParameterMapElement * > | m_multi_map_elements |
bool | m_finalized |
ParameterMap | ( | ) |
constructor
Definition at line 228 of file ParameterMap.cpp.
|
virtual |
destructor
Definition at line 233 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
Operation in O(n*log n)
Definition at line 293 of file ParameterMap.cpp.
DynArray< const SGParamInfo * > * get | ( | const SGParamInfo | key | ) | const |
Gets a specific element of the map finalize_map() has to be called first if more than one elements are in map.
Operation in O(log n)
Same as below but without pointer for syntactic ease.
parameter key: key of the element to get returns set of values of the key element
Definition at line 266 of file ParameterMap.cpp.
DynArray< const SGParamInfo * > * get | ( | const SGParamInfo * | key | ) | const |
Gets a specific element of the map. finalize_map() has to be called first if more than one elements are in map.
Operation in O(log n)
key | key of the element to get |
Definition at line 271 of file ParameterMap.cpp.
void print_map | ( | ) |
prints all elements of this map
Definition at line 364 of file ParameterMap.cpp.
void put | ( | const SGParamInfo * | key, |
const SGParamInfo * | value | ||
) |
Puts an newly allocated element into the map. Note that get(...) returns an array of value elements, so it is allowed to add multiple values for one key. Note that there is also no check for double entries, i.e. same key and same value.This will result in two elements when get is called. Operation in O(1).
key | key of the element |
value | value of the lement |
Definition at line 242 of file ParameterMap.cpp.
|
protected |
variable that indicates if its possible to call get method
Definition at line 225 of file ParameterMap.h.
|
protected |
list of CLinearMap elements, this is always kept sorted
Definition at line 218 of file ParameterMap.h.
|
protected |
hidden internal structure which is used to hold multiple values for one key. It is built when finalize_map() is called.
Definition at line 222 of file ParameterMap.h.