MCPcopy Create free account
hub / github.com/esengine/esengine / add

Method add

packages/core/src/ECS/Utils/SparseSet.ts:46–55  ·  view source on GitHub ↗

* 添加元素到集合 * * @param item 要添加的元素 * @returns 是否成功添加(false表示元素已存在)

(item: T)

Source from the content-addressed store, hash-verified

44 * @returns 是否成功添加(false表示元素已存在)
45 */
46 public add(item: T): boolean {
47 if (this._sparse.has(item)) {
48 return false; // 元素已存在
49 }
50
51 const index = this._dense.length;
52 this._dense.push(item);
53 this._sparse.set(item, index);
54 return true;
55 }
56
57 /**
58 * 从集合中移除元素

Callers 15

_getAllMethodNamesMethod · 0.45
calculateMethod · 0.45
stringifyMethod · 0.45
calculateMethod · 0.45
estimateObjectSizeMethod · 0.45
buildHotspotsMethod · 0.45
buildHotspotItemMethod · 0.45
onModeChangedMethod · 0.45
resolveMethod · 0.45

Calls 3

hasMethod · 0.65
pushMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected