-
Notifications
You must be signed in to change notification settings - Fork 0
API UInt32Array
Liu.Yandong.Hanks edited this page Aug 26, 2026
·
4 revisions
固定长度的无符号 32 位整数紧凑数组。
new UInt32Array(length) 使用初始为零的连续 uint 存储。适用于哈希、打包颜色、掩码与非负计数器。长度固定,push/pop 不可用。
UInt32Array 是用于分配高效无符号数值工作负载(如哈希、打包颜色与非负计数器)的原生支持数组。元素位于连续原生存储中,因此避免了一般 Array 的逐元素对象分配。
长度在构造时固定。push、pop 与元素删除不可用;通过数值索引读写元素。
var hashes = new UInt32Array(2);
hashes[0] = 4294967295;
return hashes[0]; // 4294967295Warning
在 0 到 length - 1 之外索引会引发运行时错误。读写前请验证计算出的索引。
值必须有符号时使用 Int32Array;元素类型必须变化或集合需要增长时使用 Array。
参数
| Name | Type | Required | 说明 |
|---|---|---|---|
length |
number |
No | 非负元素数量。省略则创建空数组。 |
Returns
UInt32Array — 固定长度数组,元素初始为 0。
示例
var colors = new UInt32Array(4);
return colors[3]; // 0Returns
number — 固定元素数量。
行为
只读。对给定实例该值永不改变。
示例
return new UInt32Array(8).length; // 8参数
| Name | Type | Required | 说明 |
|---|---|---|---|
value |
number |
No | 写入每个元素的值。默认为 0。 |
Returns
UInt32Array — 本数组,可链式调用。
行为
值在存储前转换为无符号 32 位整数,每个元素会被原地覆盖。
示例
var colors = new UInt32Array(3);
colors.fill(16711680);
return colors[2]; // 16711680AuroraScript.JIT 4.0.0 · 文档首页 · 仓库 · MIT License