/** * A generic collection used by MapsIndoors. * * @export * @abstract * @class MPCollection * @typedef {MPCollection} * @template Type */ export default abstract class MPCollection { /** * The map the objects are kept in. * * @protected * @type {!Map} */ protected map!: Map; /** * Creates an instance of MPCollection. * * @constructor * @protected */ protected constructor() { } /** * Gets all objects contained in the collection. * * @public * @returns {Array} */ public getAll(): Array { return Array.from(this.map.values()); } /** * Get a object by its identifier. * * @public * @param {string} id * @returns {(Type | undefined)} */ public getById(id: string): Type | undefined { return this.map.get(id); } /** * The number of objects in the collection. * * @public * @readonly * @type {number} */ public get size(): number { return this.map.size; } }