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.AddValue
automatically 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 anHxmValue
which 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.HxmValue
should 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¶
Returns the number of elements in the map. |
|
Erases all elements from the map. |
|
Adds the given value in the map. |
|
Adds the given integer value in the map. |
|
Adds the given double value in the map. |
|
Adds the given boolean value in the map. |
|
Adds the given expression in the map. |
|
Adds the given string value in the map. |
|
Adds the given map in the map. |
|
Adds the given function in the map. |
|
Adds the given module in the map. |
|
Returns the value associated with the given key as a HxmValue. |
|
Returns the integer value associated with the given key. |
|
Returns the double value associated with the given key. |
|
Returns the boolean value associated with the given key. |
|
Returns the string value associated with the given key. |
|
Returns the HxExpression associated with the given key. |
|
Returns the map associated with the given key. |
|
Returns the function associated with the given key. |
|
Returns the module associated with the given key. |
|
Associates the HxmValue to the given key in the map. |
|
Associates the integer value to the given key in the map. |
|
Associates the double value to the given key in the map. |
|
Associates the boolean value to the given key in the map. |
|
Associates the string value to the given key in the map. |
|
Associates the expression to the given key in the map. |
|
Associates the map to the given key in the map. |
|
Associates the function to the given key in the map. |
|
Associates the module to the given key in the map. |
|
Unsets the given key in the map if present. |
|
Returns true if the given key is defined in the map. |
|
Returns the map as a HxmValue. |
|
Returns an iterator to the elements of this map. |
|
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 (Hexaly.Optimizer.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.
- 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.
- 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
,string
orHxmValue
) – 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
,string
orHxmValue
) – 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
,string
orHxmValue
) – 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
,string
orHxmValue
) – 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
HxExpression
associated with the given key. The value must exist and must be an expression.- Arguments:
key (
long
,string
orHxmValue
) – Key searched.- Returns:
Expression associated with the key.
- Return type:
- 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.
- 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
,string
orHxmValue
) – Key searched.- Returns:
Function associated with the key.
- Return type:
- 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.
- void SetValue(long key, HxmValue value)¶
- void SetValue(string key, HxmValue value)
- void SetValue(HxmValue key, HxmValue value)
Associates the
HxmValue
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 asUnset()
.
- 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
,string
orHxmValue
) – Key to set.value (long) – Value to set.
- 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
,string
orHxmValue
) – Key to set.value (double) – Value to set.
- 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
,string
orHxmValue
) – Key to set.value (bool) – Value to set.
- 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
,string
orHxmValue
) – Key to set.value (string) – Value to set.
- 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
,string
orHxmValue
) – Key to set.value (Hexaly.Optimizer.HxExpression) – Expression to set.
- 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()
.
- 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
,string
orHxmValue
) – Key to set.value (HxmFunction) – Function to set.
- 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()
.
- 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
,string
orHxmValue
) – 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
,string
orHxmValue
) – Key to search.
- 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