38 lines
769 B
TypeScript
38 lines
769 B
TypeScript
import * as plugins from './classes.plugins.js';
|
|
|
|
import { ObjectMap } from './classes.objectmap.js';
|
|
|
|
export class LoopTracker<T> {
|
|
referenceObjectMap = new ObjectMap<any>();
|
|
constructor() {
|
|
// nothing here
|
|
}
|
|
|
|
/**
|
|
* checks and tracks an object
|
|
* @param objectArg
|
|
*/
|
|
checkAndTrack(objectArg: T): boolean {
|
|
if (!this.referenceObjectMap.checkForObject(objectArg)) {
|
|
this.referenceObjectMap.add(objectArg);
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* resets the loop tracker, clearing all tracked objects
|
|
*/
|
|
public reset() {
|
|
this.referenceObjectMap.wipe();
|
|
}
|
|
|
|
/**
|
|
* destroys the loop tracker and its underlying ObjectMap
|
|
*/
|
|
public destroy() {
|
|
this.referenceObjectMap.destroy();
|
|
}
|
|
}
|