Home > @esengine/ecs-framework-monorepo > SparseSet > forEach
SparseSet.forEach() method
遍历集合中的所有元素
保证遍历顺序与添加顺序一致(除非中间有删除操作)。 遍历性能优秀,因为数据在内存中连续存储。
Signature:
typescript
forEach(callback: (item: T, index: number) => void): void;
Parameters
Parameter | Type | Description |
---|---|---|
callback | (item: T, index: number) => void | 遍历回调函数 |
Returns:
void