UNPKG

astl

Version:

AssemblyScript-STL (Standard Template Library, migrated from the C++)

47 lines (41 loc) 864 B
export class Repeater<T> { private index_: usize; private readonly value_: T; public constructor(index: usize, value: T) { this.index_ = index; this.value_ = value; } @inline public index(): usize { return this.index_; } @inline public get value(): T { return this.value_; } @inline public next(): Repeater<T> { ++this.index_; return this; } @operator("==") @inline public equals(obj: Repeater<T>): boolean { const ret: boolean = this.index_ === obj.index_; if (ret === true) this.index_ = 0; return ret; } @operator("!=") @inline protected __non_equals(obj: Repeater<T>): boolean { return !this.equals(obj); } }