HxmMap Class¶
-
class
Hexaly.Modeler.HxmMap¶ An HxmMap is a data structure mapping keys to values. A map is both an associative table and an array. Setting a value to an existing key will overwrite any value previously set for that key.
When used as an array-like structure, adding a new unkeyed element to an HxmMap with
HxmMap.AddValueautomatically assigns an integer key to the element equal to the largest integer key already present plus one, or zero if no integer key exists.Most of the functions below exist in multiple versions: values and keys can be manipulated through their native type (like
int,double,string,HxmMap,HxmFunction…) or manipulated with anHxmValuewhich is a container that can hold any type of value. Using the native type is more convenient and results in less overhead most of the time.HxmValueshould only be used when you don’t know the type of the manipulated value.The enumerators returned by the method
GetEnumerator()follow the fail-fast convention: if the map is structurally modified after the creation of an enumerator (by using the methods Add, Set, Unset or Clear), the enumerator will throw an exception. In other words, you can’t modify a map while you are iterating over it.Since: 10.0
Summary¶
Count |
Returns the number of elements in the map. |
Clear |
Erases all elements from the map. |
AddValue |
Adds the given value in the map. |
AddInt |
Adds the given integer value in the map. |
AddDouble |
Adds the given double value in the map. |
AddBool |
Adds the given boolean value in the map. |
AddExpression |
Adds the given expression in the map. |
AddString |
Adds the given string value in the map. |
AddMap |
Adds the given map in the map. |
AddFunction |
Adds the given function in the map. |
AddModule |
Adds the given module in the map. |
AddClass |
Adds the given class in the map. |
GetValue |
Returns the value associated with the given key as a HxmValue. |
GetInt |
Returns the integer value associated with the given key. |
GetDouble |
Returns the double value associated with the given key. |
GetBool |
Returns the boolean value associated with the given key. |
GetString |
Returns the string value associated with the given key. |
GetExpression |
Returns the HxExpression associated with the given key. |
GetMap |
Returns the map associated with the given key. |
GetFunction |
Returns the function associated with the given key. |
GetModule |
Returns the module associated with the given key. |
GetClass |
Returns the class associated with the given key. |
SetValue |
Associates the HxmValue to the given key in the map. |
SetInt |
Associates the integer value to the given key in the map. |
SetDouble |
Associates the double value to the given key in the map. |
SetBool |
Associates the boolean value to the given key in the map. |
SetString |
Associates the string value to the given key in the map. |
SetExpression |
Associates the expression to the given key in the map. |
SetMap |
Associates the map to the given key in the map. |
SetFunction |
Associates the function to the given key in the map. |
SetModule |
Associates the module to the given key in the map. |
SetClass |
Associates the class to the given key in the map. |
Unset |
Unsets the given key in the map if present. |
IsDefined |
Returns true if the given key is defined in the map. |
AsValue |
Returns the map as a HxmValue. |
GetEnumerator |
Returns an iterator to the elements of this map. |
Dispose |
Releases the reference. |
Instance methods¶
-
long
Count()¶ Returns the number of elements in the map.
-
void
Clear()¶ Erases all elements from the map. After this call,
HxmMap.Count()returns zero.
-
void
AddValue(HxmValue value)¶ Adds the given value in the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Arguments: value (HxmValue) – Value to add in the map.
-
void
AddInt(long value)¶ Adds the given integer value in the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Arguments: value ( long) – Value to add in the map.
-
void
AddDouble(double value)¶ Adds the given double value in the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Arguments: value ( double) – Value to add in the map.
-
void
AddBool(bool value)¶ Adds the given boolean value in the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Arguments: value ( bool) – Value to add in the map.
-
void
AddExpression(Hexaly.Optimizer.HxExpression expr)¶ Adds the given expression in the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Arguments: expr ( HxExpression) – Value to add in the map.
-
void
AddString(string value)¶ Adds the given string value in the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Arguments: value ( string) – Value to add in the map.
-
void
AddMap(HxmMap map)¶ Adds the given map in the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Arguments: map ( HxmMap) – Map to add in the map.
-
void
AddFunction(HxmFunction function)¶ Adds the given function in the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Arguments: function ( HxmFunction) – Function to add in the map.
-
void
AddModule(HxmModule module)¶ Adds the given module in the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Arguments: module ( HxmModule) – Module to add in the map.
-
void
AddClass(HxmClass clazz)¶ Adds the given class in the map. The associated key corresponds to the largest integer key present in the map plus one, or zero if no integer key exists.
Since: 13.0 Arguments: clazz ( HxmClass) – Class to add in the map.
-
HxmValue
GetValue(long key)¶ -
HxmValue
GetValue(string key) -
HxmValue
GetValue(HxmValue key) Returns the value associated with the given key as a
HxmValue. If no value is associated with the key, an HxmValue representing nil is returned.Arguments: key ( long,stringorHxmValue) – Key searched.Returns: Value associated with the key. Return type: HxmValue
-
long
GetInt(long key)¶ -
long
GetInt(string key) -
long
GetInt(HxmValue key) Returns the integer value associated with the given key. The value must exist and must be an integer.
Arguments: key ( long,stringorHxmValue) – Key searched.Returns: Integer value associated with the key. Return type: long
-
double
GetDouble(long key)¶ -
double
GetDouble(string key) -
double
GetDouble(HxmValue key) Returns the double value associated with the given key. The value must exist and must be a double.
Arguments: key ( long,stringorHxmValue) – Key searched.Returns: Double value associated with the key. Return type: double
-
bool
GetBool(long key)¶ -
bool
GetBool(string key) -
bool
GetBool(HxmValue key) Returns the boolean value associated with the given key. The value must exist and must be a boolean.
Arguments: key ( long,stringorHxmValue) – Key searched.Returns: Boolean value associated with the key. Return type: bool
-
string
GetString(long key)¶ -
string
GetString(string key) -
string
GetString(HxmValue key) Returns the string value associated with the given key. The value must exist and must be a string.
Arguments: key ( long,stringorHxmValue) – Key searched.Returns: String value associated with the key. Return type: string
-
Hexaly.Optimizer.HxExpression
GetExpression(long key)¶ -
Hexaly.Optimizer.HxExpression
GetExpression(string key) -
Hexaly.Optimizer.HxExpression
GetExpression(HxmValue key) Returns the
HxExpressionassociated with the given key. The value must exist and must be an expression.Arguments: key ( long,stringorHxmValue) – Key searched.Returns: Expression associated with the key. Return type: HxExpression
-
HxmMap
GetMap(long key)¶ -
HxmMap
GetMap(string key) -
HxmMap
GetMap(HxmValue key) Returns the map associated with the given key. The value must exist and must be a map.
Arguments: key ( long,stringorHxmValue) – Key searched.Returns: Map associated with the key. Return type: HxmMap
-
HxmFunction
GetFunction(long key)¶ -
HxmFunction
GetFunction(string key) -
HxmFunction
GetFunction(HxmValue key) Returns the function associated with the given key. The value must exist and must be a function.
Arguments: key ( long,stringorHxmValue) – Key searched.Returns: Function associated with the key. Return type: HxmFunction
-
HxmModule
GetModule(long key)¶ -
HxmModule
GetModule(string key) -
HxmModule
GetModule(HxmValue key) Returns the module associated with the given key. The value must exist and must be a module.
Arguments: key ( long,stringorHxmValue) – Key searched.Returns: Module associated with the key. Return type: HxmModule
-
HxmClass
GetClass(long key)¶ -
HxmClass
GetClass(string key) -
HxmClass
GetClass(HxmValue key) Returns the class associated with the given key. The value must exist and must be a class.
Since: 13.0 Arguments: key ( long,stringorHxmValue) – Key searched.Returns: Class associated with the key. Return type: HxmClass
-
void
SetValue(long key, HxmValue value)¶ -
void
SetValue(string key, HxmValue value) -
void
SetValue(HxmValue key, HxmValue value) Associates the
HxmValueto the given key in the map. If the map already contained an association for the key, the previous value is replaced. The key must not be nil. If the value is nil, this has the same effect asUnset().Arguments:
-
void
SetInt(long key, long value)¶ -
void
SetInt(string key, long value) -
void
SetInt(HxmValue key, long value) Associates the integer value to the given key in the map. If the map already contained an association for the key, the previous value is replaced. The key must not be nil. If the value is nil, this has the same effect as
Unset().Arguments: - key (
long,stringorHxmValue) – Key to set. - value (
long) – Value to set.
- key (
-
void
SetDouble(long key, double value)¶ -
void
SetDouble(string key, double value) -
void
SetDouble(HxmValue key, double value) Associates the double value to the given key in the map. If the map already contained an association for the key, the previous value is replaced. The key must not be nil. If the value is nil, this has the same effect as
Unset().Arguments: - key (
long,stringorHxmValue) – Key to set. - value (
double) – Value to set.
- key (
-
void
SetBool(long key, bool value)¶ -
void
SetBool(string key, bool value) -
void
SetBool(HxmValue key, bool value) Associates the boolean value to the given key in the map. If the map already contained an association for the key, the previous value is replaced. The key must not be nil. If the value is nil, this has the same effect as
Unset().Arguments: - key (
long,stringorHxmValue) – Key to set. - value (
bool) – Value to set.
- key (
-
void
SetString(long key, string value)¶ -
void
SetString(string key, string value) -
void
SetString(HxmValue key, string value) Associates the string value to the given key in the map. If the map already contained an association for the key, the previous value is replaced. The key must not be nil. If the value is nil, this has the same effect as
Unset().Arguments: - key (
long,stringorHxmValue) – Key to set. - value (
string) – Value to set.
- key (
-
void
SetExpression(long key, Hexaly.Optimizer.HxExpression expr)¶ -
void
SetExpression(string key, Hexaly.Optimizer.HxExpression expr) -
void
SetExpression(HxmValue key, Hexaly.Optimizer.HxExpression expr) Associates the expression to the given key in the map. If the map already contained an association for the key, the previous value is replaced. The key must not be nil. If the value is nil, this has the same effect as
Unset().Arguments: - key (
long,stringorHxmValue) – Key to set. - expr (
HxExpression) – Expression to set.
- key (
-
void
SetMap(long key, HxmMap map)¶ -
void
SetMap(string key, HxmMap map) -
void
SetMap(HxmValue key, HxmMap map) Associates the map to the given key in the map. If the map already contained an association for the key, the previous value is replaced. The key must not be nil. If the value is nil, this has the same effect as
Unset().Arguments:
-
void
SetFunction(long key, HxmFunction function)¶ -
void
SetFunction(string key, HxmFunction function) -
void
SetFunction(HxmValue key, HxmFunction function) Associates the function to the given key in the map. If the map already contained an association for the key, the previous value is replaced. The key must not be nil. If the value is nil, this has the same effect as
Unset().Arguments: - key (
long,stringorHxmValue) – Key to set. - function (
HxmFunction) – Function to set.
- key (
-
void
SetModule(long key, HxmModule module)¶ -
void
SetModule(string key, HxmModule module) -
void
SetModule(HxmValue key, HxmModule module) Associates the module to the given key in the map. If the map already contained an association for the key, the previous value is replaced. The key must not be nil. If the value is nil, this has the same effect as
Unset().Arguments:
-
void
SetClass(long key, HxmClass clazz)¶ -
void
SetClass(string key, HxmClass clazz) -
void
SetClass(HxmValue key, HxmClass clazz) Associates the class to the given key in the map. If the map already contained an association for the key, the previous value is replaced. The key must not be nil. If the value is nil, this has the same effect as
Unset().Arguments:
-
void
Unset(long key)¶ -
void
Unset(string key) -
void
Unset(HxmValue key) Unsets the given key in the map if present. If the key doesn’t exist in the map do nothing. The key must not be nil.
Arguments: key ( long,stringorHxmValue) – Key to unset.
-
bool
IsDefined(long key)¶ -
bool
IsDefined(string key) -
bool
IsDefined(HxmValue key) Returns true if the given key is defined in the map.
Arguments: key ( long,stringorHxmValue) – Key to search.
-
HxmValue
AsValue()¶ Returns the map as a
HxmValue.Returns: The map as an HxmValue. Return type: HxmValue
-
IEnumerator<KeyValuePair<HxmValue,
GetEnumerator()¶ Returns an iterator to the elements of this map.
Returns: Iterator to the elements of this map. Return type: IEnumerator
-
void
Dispose()¶ Releases the reference. If this map was already released, returns immediately and does nothing. Invoking any method on this object after this operation will throw an exception.
Note: Releasing a reference does not necessarily imply that the underlying map object is destroyed. It is only destroyed if no more references point to it.
Since: 11.5