Skip to content

API Host ScriptHashMap

Liu.Yandong.Hanks edited this page Aug 19, 2026 · 3 revisions

ScriptHashMap

可供宿主创建或检查的高性能运行时哈希表。

High-performance runtime hash map that hosts may create or inspect.

命名空间:AuroraScript.Runtime.Types。类型:class。

Namespace: AuroraScript.Runtime.Types. Kind: class.

返回 .NET Host API 参考

Back to .NET Host API Reference

用途

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); // 42

成员

Members

Constructor

签名

  • ScriptHashMap()
  • ScriptHashMap(int capacity)

创建 ScriptHashMap 实例。

Use the member according to its public signature.

Parameters:

  • capacity
    初始预留容量。

    Initial reserved capacity.

Returns

新建的 ScriptHashMap 实例。

A new ScriptHashMap instance.

调用示意

以下示例展示调用形状;将占位实例和参数替换为宿主中的实际值。

The example shows the call shape; replace placeholder instances and arguments with actual host values.

var value = new ScriptHashMap(/* 参数 */);

void Put(ScriptDatum key, ScriptDatum value)

调用 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 */);

ScriptDatum Get(ScriptDatum key)

调用 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 */);

GetOrInsert

签名

  • 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 */);

bool Has(ScriptDatum key)

调用 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 */);

ScriptDatum Delete(ScriptDatum 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 */);

ScriptDatum[] Keys()

调用 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();

ScriptDatum[] Values()

调用 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();

int Length()

调用 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();

void Clear()

调用 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();

Clone this wiki locally