-
Notifications
You must be signed in to change notification settings - Fork 0
API Host ScriptHashMap
可供宿主创建或检查的高性能运行时哈希表。
High-performance runtime hash map that hosts may create or inspect.
命名空间:AuroraScript.Runtime.Types。类型:class。
Namespace:
AuroraScript.Runtime.Types. Kind: class.
Purpose
ScriptHashMap 是公开宿主类型。通过下方签名选择调用方式;对运行时对象、生命周期和异常,应由宿主在边界处明确处理。
High-performance runtime hash map that hosts may create or inspect.
Simple Example
下面是 ScriptHashMap 的最小使用方式。
A minimal use of
ScriptHashMap.
var map = new ScriptHashMap();
var key = ScriptDatum.FromString("answer");
map.Put(key, ScriptDatum.FromNumber(42));
Console.WriteLine(map.Get(key).Number); // 42Members
签名
ScriptHashMap()ScriptHashMap(int capacity)
创建 ScriptHashMap 实例。
Use the member according to its public signature.
Parameters:
-
capacity
初始预留容量。Initial reserved capacity.
Returns
新建的 ScriptHashMap 实例。
A new
ScriptHashMapinstance.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
var value = new ScriptHashMap(/* 参数 */);调用 Put 完成其公开操作。
Use the member according to its public signature.
Parameters:
-
key
要查找或保存的键。Key to look up or store.
-
value
要处理、保存或转换的值。Value to process, store, or convert.
Returns
无。
None.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptHashMap value = /* 从宿主 API 获取实例 */;
value.Put(/* key */, /* value */);调用 Get 完成其公开操作。
Use the member according to its public signature.
Parameters:
-
key
要查找或保存的键。Key to look up or store.
Returns
返回 ScriptDatum。
Returns
ScriptDatum.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptHashMap value = /* 从宿主 API 获取实例 */;
var result = value.Get(/* key */);签名
ScriptDatum GetOrInsert(ScriptDatum key, ScriptDatum value)ScriptDatum GetOrInsert(ScriptContext ctx, ScriptDatum key, ClosureFunction callback)
调用 GetOrInsert 完成其公开操作。
Use the member according to its public signature.
Parameters:
-
key
要查找或保存的键。Key to look up or store.
-
value
要处理、保存或转换的值。Value to process, store, or convert.
-
ctx
当前脚本执行上下文。Current script execution context.
-
callback
由运行时调用的回调。Callback invoked by the runtime.
Returns
返回 ScriptDatum。
Returns
ScriptDatum.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptHashMap value = /* 从宿主 API 获取实例 */;
var result = value.GetOrInsert(/* key */, /* value */);调用 Has 完成其公开操作。
Use the member according to its public signature.
Parameters:
-
key
要查找或保存的键。Key to look up or store.
Returns
返回 bool。
Returns
bool.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptHashMap value = /* 从宿主 API 获取实例 */;
var result = value.Has(/* key */);调用 Delete 完成其公开操作。
Use the member according to its public signature.
Parameters:
-
key
要查找或保存的键。Key to look up or store.
Returns
返回 ScriptDatum。
Returns
ScriptDatum.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptHashMap value = /* 从宿主 API 获取实例 */;
var result = value.Delete(/* key */);调用 Keys 完成其公开操作。
Use the member according to its public signature.
Parameters:
- 无。
None.
Returns
返回 ScriptDatum[]。
Returns
ScriptDatum[].
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptHashMap value = /* 从宿主 API 获取实例 */;
var result = value.Keys();调用 Values 完成其公开操作。
Use the member according to its public signature.
Parameters:
- 无。
None.
Returns
返回 ScriptDatum[]。
Returns
ScriptDatum[].
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptHashMap value = /* 从宿主 API 获取实例 */;
var result = value.Values();调用 Length 完成其公开操作。
Use the member according to its public signature.
Parameters:
- 无。
None.
Returns
返回 int。
Returns
int.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptHashMap value = /* 从宿主 API 获取实例 */;
var result = value.Length();调用 Clear 完成其公开操作。
Use the member according to its public signature.
Parameters:
- 无。
None.
Returns
无。
None.
调用示意
以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。
The example shows the call shape; replace placeholder instances and arguments with actual host values.
ScriptHashMap value = /* 从宿主 API 获取实例 */;
value.Clear();AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License