set_dict_tupleT_set_dict_tupleSetDictTupleSetDictTuple (Operator)

Name

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

Signature

set_dict_tuple( : : DictHandle, Key, Tuple : )

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

void SetDictTuple(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)

static void HOperatorSet.SetDictTuple(HTuple dictHandle, HTuple key, HTuple tuple)

void HDict.SetDictTuple(HTuple key, HTuple tuple)

void HDict.SetDictTuple(string key, HTuple tuple)

Description

set_dict_tupleset_dict_tupleSetDictTupleSetDictTupleSetDictTuple stores a tuple associated with a key in the dictionary. The dictionary is denoted by the DictHandleDictHandleDictHandleDictHandledictHandle parameter.

TupleTupleTupleTupletuple 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 (KeyKeyKeyKeykey), the old data is destroyed by set_dict_tupleset_dict_tupleSetDictTupleSetDictTupleSetDictTuple and replaced by TupleTupleTupleTupletuple.

The KeyKeyKeyKeykey 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_tupleget_dict_tupleGetDictTupleGetDictTupleGetDictTuple.

Attention

Note that if the tuple contains any handles (which are treated as simple integers) only the handle values are copied by the operation, not the resources behind those handles.

Execution Information

This operator modifies the state of the following input parameter:

The value of this parameter may not be shared across multiple threads without external synchronization.

Parameters

DictHandleDictHandleDictHandleDictHandledictHandle (input_control, state is modified)  dict HDict, HTupleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Dictionary handle.

Number of elements: DictHandle == 1

KeyKeyKeyKeykey (input_control)  string HTupleHTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)

Key string.

Number of elements: Key == 1

Restriction: length(Key) > 0

TupleTupleTupleTupletuple (input_control)  tuple-array HTupleHTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)

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_tupleset_dict_tupleSetDictTupleSetDictTupleSetDictTuple returns 2 (H_MSG_TRUE). Otherwise an exception is raised. Possible error conditions include invalid parameters (handle or key) or resource allocation error.

Possible Predecessors

create_dictcreate_dictCreateDictCreateDictCreateDict

Possible Successors

set_dict_objectset_dict_objectSetDictObjectSetDictObjectSetDictObject

Alternatives

set_dict_objectset_dict_objectSetDictObjectSetDictObjectSetDictObject

See also

create_dictcreate_dictCreateDictCreateDictCreateDict, get_dict_tupleget_dict_tupleGetDictTupleGetDictTupleGetDictTuple, set_dict_objectset_dict_objectSetDictObjectSetDictObjectSetDictObject, get_dict_objectget_dict_objectGetDictObjectGetDictObjectGetDictObject, get_dict_paramget_dict_paramGetDictParamGetDictParamGetDictParam, remove_dict_keyremove_dict_keyRemoveDictKeyRemoveDictKeyRemoveDictKey

Module

Foundation