set_dict_tuple_atT_set_dict_tuple_atSetDictTupleAtSetDictTupleAtset_dict_tuple_at (算子)

名称

set_dict_tuple_atT_set_dict_tuple_atSetDictTupleAtSetDictTupleAtset_dict_tuple_at — 为字典中的一个或多个元组元素分配一个或几个值。

签名

set_dict_tuple_at( : : DictHandle, Key, Index, Value : )

Herror T_set_dict_tuple_at(const Htuple DictHandle, const Htuple Key, const Htuple Index, const Htuple Value)

void SetDictTupleAt(const HTuple& DictHandle, const HTuple& Key, const HTuple& Index, const HTuple& Value)

void HDict::SetDictTupleAt(const HTuple& Key, const HTuple& Index, const HTuple& Value) const

void HDict::SetDictTupleAt(const HString& Key, const HTuple& Index, const HTuple& Value) const

void HDict::SetDictTupleAt(const char* Key, const HTuple& Index, const HTuple& Value) const

void HDict::SetDictTupleAt(const wchar_t* Key, const HTuple& Index, const HTuple& Value) const   ( Windows only)

static void HOperatorSet.SetDictTupleAt(HTuple dictHandle, HTuple key, HTuple index, HTuple value)

void HDict.SetDictTupleAt(HTuple key, HTuple index, HTuple value)

void HDict.SetDictTupleAt(string key, HTuple index, HTuple value)

def set_dict_tuple_at(dict_handle: HHandle, key: Union[str, int], index: Sequence[int], value: Sequence[HTupleElementType]) -> None

描述

set_dict_tuple_atset_dict_tuple_atSetDictTupleAtSetDictTupleAtSetDictTupleAtset_dict_tuple_at assigns a single value to one or several elements of a tuple, or it assigns a number of values elementwise to the specified elements of a tuple that is stored in DictHandleDictHandleDictHandleDictHandledictHandledict_handle under the key KeyKeyKeyKeykeykey. The operator allows to efficiently replace parts of a tuple stored in a dictionary without first reading the previous values from the dictionary.

If the dictionary does not yet contain a tuple under the given key, or if the given key maps to an iconic value, a new tuple is created and stored under the given key. In the latter case, the iconic object previously stored under that key is removed from the dictionary.

If the passed indices are out of the current range of the tuple stored in the dictionary, the tuple length is increased and the new values are initialized to a default value.

The KeyKeyKeyKeykeykey has to be a string or an integer. Strings are treated case sensitive. The IndexIndexIndexIndexindexindex parameter can be any expression that evaluates to any number of positive integer values. The ValueValueValueValuevaluevalue parameter must evaluate to exactly one value or to the same number of indices that are provided via the IndexIndexIndexIndexindexindex parameter.:

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

注意

Note that if ValueValueValueValuevaluevalue contains any handles, only the handle values are copied by the operation, not the resources behind those handles.

执行信息

此算子修改后续输入参数的状态:

在执行此算子时,若该参数值需在多个线程间使用,则必须对其访问进行同步。

参数

DictHandleDictHandleDictHandleDictHandledictHandledict_handle (输入控制,状态被修改)  dict HDict, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Dictionary handle.

元素数量: DictHandle == 1

KeyKeyKeyKeykeykey (输入控制)  string HTupleUnion[str, int]HTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)

Key string.

元素数量: Key == 1

限制: length(Key) > 0

IndexIndexIndexIndexindexindex (输入控制)  integer-array HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Indices of the elements that have to be replaced by the new value(s).

默认值: 0

建议值: 0, 1, 2, 3, 4, 5, 6

最小增量: 1

ValueValueValueValuevaluevalue (输入控制)  tuple-array HTupleSequence[HTupleElementType]HTupleHtuple (string / integer / real / handle) (string / int / long / double / HHandle) (HString / Hlong / double / HHandle) (char* / Hlong / double / handle)

Value(s) that is to be assigned.

示例(HDevelop)

Dict := dict{}
Dict.some_key := 27

set_dict_tuple_at (Dict, 'some_key', 1, 5)
* Dict.some_key is now [27, 5]

* Alternative TRIAS syntax
Dict.some_key[0] := 66
* Dict.some_key is now [66, 5]

结果

If the operation succeeds, set_dict_tuple_atset_dict_tuple_atSetDictTupleAtSetDictTupleAtSetDictTupleAtset_dict_tuple_at 返回 2 ( H_MSG_TRUE )。否则将抛出异常。 Possible error conditions include invalid parameters or resource allocation error.

可能的前趋

create_dictcreate_dictCreateDictCreateDictCreateDictcreate_dict

可能的后继

set_dict_tupleset_dict_tupleSetDictTupleSetDictTupleSetDictTupleset_dict_tuple, get_dict_tupleget_dict_tupleGetDictTupleGetDictTupleGetDictTupleget_dict_tuple

替代

set_dict_tupleset_dict_tupleSetDictTupleSetDictTupleSetDictTupleset_dict_tuple

另见

create_dictcreate_dictCreateDictCreateDictCreateDictcreate_dict, set_dict_tupleset_dict_tupleSetDictTupleSetDictTupleSetDictTupleset_dict_tuple, get_dict_tupleget_dict_tupleGetDictTupleGetDictTupleGetDictTupleget_dict_tuple, set_dict_objectset_dict_objectSetDictObjectSetDictObjectSetDictObjectset_dict_object, get_dict_objectget_dict_objectGetDictObjectGetDictObjectGetDictObjectget_dict_object, get_dict_paramget_dict_paramGetDictParamGetDictParamGetDictParamget_dict_param, remove_dict_keyremove_dict_keyRemoveDictKeyRemoveDictKeyRemoveDictKeyremove_dict_key

模块

基础