SMap containers are data types composed of a paired collection of unique keys (strings) and values (SObject), where each key is associated with one value. There are currently two different implementations of the SMap container.
The iterator (SIterator) implementation returns an element (as SObject) of the map for the SIteratorObject() function call. When a key-value pair is unlinked from the map with SIteratorUnlink(), the key is freed, and the value is returned (as SObject). The SMap iterator implements the SIteratorKey() call and returns the key of a key-value pair.
A map object.
An abstract data type composed of a collection of unique string keys and a collection of values (of type SObject), where each key is associated with one value.
The map class structure.
It inherits from SContainer so that it supports different map implementations.
Get the signed integer value of the named key.
Parameters: |
|
---|---|
Note: | An S_ARGERROR error is set if the named key is not in the map. |
See also: | |
Return: | The signed integer value of the named key. |
Get the float value of the named key.
Parameters: |
|
---|---|
Note: | An S_ARGERROR error is set if the named key is not in the map. |
See also: | |
Return: | The float value of the named key. |
Get the string value of the named key.
Parameters: |
|
---|---|
Note: | An S_ARGERROR error is set if the named key is not in the map. |
See also: | |
Return: | Pointer to the string of the named key. |
Get the object of the named key.
Parameters: |
|
---|---|
Note: | An S_ARGERROR error is set if the named key is not in the map. |
See also: | |
Return: | Pointer to the object of the named key. |
Get a list of the keys in the map container.
Parameters: |
|
---|---|
Return: | SList of keys in container, or NULL if the container is empty. The list objects (keys) are string objects and are accessed with SObjectGetString. |
Note: | The caller is responsible for the memory of the returned SList object. |
Get the signed integer value of the named key.
If the named key is not found then use the given default.
Parameters: |
|
---|---|
See also: | |
Return: | The signed integer value of the named key, or given default value. |
Get the float value of the named key.
If the named key is not found then use the given default.
Parameters: |
|
---|---|
See also: | |
Return: | The float value of the named key, or given default value. |
Get the string value of the named key.
If the named key is not found then use the given default.
Parameters: |
|
---|---|
See also: | |
Return: | Pointer to the string of the named key, or given default value. |
Get the SObject of the named key.
If the named key is not found then use the given default.
Parameters: |
|
---|---|
See also: | |
Return: | Pointer to the SObject of the named key, or given default value. |
Set the value of the named key as a signed integer value.
If the named key already exists then it’s data will be replaced.
Parameters: |
|
---|
Set the value of the named key as a float value.
If the named key already exists then it’s data will be replaced.
Parameters: |
|
---|
Set the value of the named key as a string value.
If the named key already exists then it’s data will be replaced.
Parameters: |
|
---|
Set the value of the named key as an SObject.
If the named key already exists then it’s SObject will be deleted (if not referenced) and replaced.
Parameters: |
|
---|---|
Note: | The map takes hold of the object, and therefore the object should not be deleted with a call to S_DELETE, see SMapObjectDelete and SMapObjectUnlink. |
Delete the named key-value pair from the map.
Key is removed from list and value deleted if it doesn’t have any references.
Parameters: |
|
---|
Remove named key-value pair from the map.
Key is removed (freed) from list and value object is returned.
Parameters: |
|
---|---|
Return: | SObject of named key. |
Copy (shallow) the key-value pairs from src to dst.
If dst does not exist a new one will be created.
Parameters: |
|
---|---|
Return: | Pointer to destination key-value map. |
Note: | Values in dst with the same named keys as in src will be overwritten with the values in src. |
Two different implementations of the SMap container:
SMapHashTable is an implementation of SMap, where the underlying data structure is a hash table.
The SMapHashTable structure.
Inherits and implements SMap as a hash table.
Resize a SMapHashTable‘s hash table.
Resize the hash table to a specific size. When a new SMapHashTable is created with S_NEW(“SMapHashTable”), the hash table’s size is set to contain 128 elements. This function is useful if a rough estimate of the number of objects that will be contained in the map is known beforehand, as it can save some memory, and growing a table is an relatively expensive operation. Resizing before any objects are added is comparatively cheap.
The hash table can be resized to any size as long as it can still contain all the existing objects in it. There are a few outcomes based on the given size and the elements contained in the hash table:
Parameters: |
|
---|