mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
18 lines
365 B
TypeScript
18 lines
365 B
TypeScript
/// <reference path="../assembly.d.ts" />
|
|
|
|
@global()
|
|
class Array<T> {
|
|
|
|
length: i32;
|
|
readonly capacity: i32;
|
|
readonly data: usize;
|
|
|
|
constructor(capacity: i32) {
|
|
if (capacity < 0)
|
|
throw new RangeError("capacity out of bounds");
|
|
this.length = capacity;
|
|
this.capacity = capacity;
|
|
this.data = Memory.allocate(sizeof<T>() * capacity);
|
|
}
|
|
}
|