Skip to content

set_dict_tupleSetDictTupleSetDictTupleset_dict_tupleT_set_dict_tuple🔗

Short description🔗

set_dict_tupleSetDictTupleSetDictTupleset_dict_tupleT_set_dict_tuple — Add a key/tuple pair to the dictionary.

Signature🔗

set_dict_tuple( dict DictHandle, string Key, tuple Tuple )void SetDictTuple( const HTuple& DictHandle, const HTuple& Key, const HTuple& Tuple )static void HOperatorSet.SetDictTuple( HTuple dictHandle, HTuple key, HTuple tuple )def set_dict_tuple( dict_handle: HHandle, key: MaybeSequence[Union[str, int]], tuple: Sequence[HTupleElementType] ) -> None

Herror T_set_dict_tuple( const Htuple DictHandle, const Htuple Key, const Htuple Tuple )

void HDict::SetDictTuple( const HTuple& Key, const HTuple& Tuple ) const

void HDict::SetDictTuple( const HString& Key, const HTuple& Tuple ) const

void HDict::SetDictTuple( const char* Key, const HTuple& Tuple ) const

void HDict::SetDictTuple( const wchar_t* Key, const HTuple& Tuple ) const (Windows only)

void HDict.SetDictTuple( HTuple key, HTuple tuple )

void HDict.SetDictTuple( string key, HTuple tuple )

Description🔗

set_dict_tupleSetDictTuple stores a tuple associated with a key in the dictionary. The dictionary is denoted by the DictHandledictHandledict_handle parameter.

Tupletupletuple including strings is copied by the operation, and can thus be immediately reused. An empty tuple is considered as a valid value that can be associated with the key. If any data (tuple or object) was already associated with given key (Keykeykey), the old data is destroyed by set_dict_tupleSetDictTuple and replaced by Tupletupletuple.

The Keykeykey has to be a string or an integer. Strings are treated case sensitive.

The tuple data for the given key can be retrieved again from the dictionary using get_dict_tupleGetDictTuple.

set_dict_tupleSetDictTuple allows setting the values of multiple keys with a single call. In this case, the length of Tupletupletuple must either be equal to the number of keys or 11. In the first case, Tupletupletuple is split into segments of length 11, one for each key. In the second case, if Tupletupletuple has length 11, that one value is associated with each key. If no keys are passed, the values in Tupletupletuple are ignored. The following table summarizes the possible combinations of number of keys and values, where N is an arbitrary non-negative integer:

Length of Keykeykey Length of Tupletupletuple Effect
N 1 Value in Tupletupletuple is associated with all keys
1 N Associate Tupletupletuple with Keykeykey
N N Associate tuples of length 11 with each passed key

HDevelop In-line Operation🔗

HDevelop provides an in-line operation for set_dict_tupleSetDictTuple, which can be used in an expression in the following syntax:

  • Dynamic syntax:

    DictHandle.['Key'] := ['The answer', 42]

  • Static syntax:

    DictHandle.Key := ['The answer', 42]

Attention🔗

If the tuple contains any handles only the handle values are copied by the operation, not the resources behind those handles (no deep copy is created).

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

This operator modifies the state of the following input parameter:

During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.

Parameters🔗

DictHandledictHandledict_handle (input_control, state is modified) dict → (handle)HTuple (HHandle)HDict, HTuple (IntPtr)HHandleHtuple (handle)

Dictionary handle.

Number of elements: DictHandle == 1

Keykeykey (input_control) string(-array) → (string / integer)HTuple (HString / Hlong)HTuple (string / int / long)MaybeSequence[Union[str, int]]Htuple (char* / Hlong)

Key string.

Tupletupletuple (input_control) tuple-array → (string / integer / real / handle)HTuple (HString / Hlong / double / HHandle)HTuple (string / int / long / double / HHandle)Sequence[HTupleElementType]Htuple (char* / Hlong / double / handle)

Tuple value to be associated with the key.

Example🔗

(HDevelop)

create_dict (Dict)
set_dict_tuple (Dict, 'simple_integer', 27)
set_dict_tuple (Dict, 'simple_string', 'Hello world')
set_dict_tuple (Dict, 'mixed_tuple', ['The answer', 42])
set_dict_tuple (Dict, 0, 'This is zero')

Result🔗

If the operation succeeds, set_dict_tupleSetDictTuple returns 2 (H_MSG_TRUE). Otherwise an exception is raised. Possible error conditions include invalid parameters (handle or key) or resource allocation error.

Combinations with other operators🔗

Combinations

Possible predecessors

create_dictCreateDict

Possible successors

set_dict_tupleSetDictTuple, set_dict_objectSetDictObject

Alternatives

set_dict_objectSetDictObject, set_dict_tuple_atSetDictTupleAt

See also

create_dictCreateDict, set_dict_tuple_atSetDictTupleAt, get_dict_tupleGetDictTuple, set_dict_objectSetDictObject, get_dict_objectGetDictObject, get_dict_paramGetDictParam, remove_dict_keyRemoveDictKey

Module🔗

Foundation