import type { Vertex } from './vertex'; import { type GraphCallbacks, SpreadsheetVertexBase } from './spreadsheet_vertex_base'; import type { Area, ICellAddress2 } from '../../../treb-base-types/src/index'; /** * this is a new cut at array vertices. unlike the old version, we are not * trying to reduce the number of vertices (and in fact we won't). this is * to handle the case of unbounded arrays (full rows or columns). * * standard behavior with an array is to create all vertices when the reference * is created (this is wasteful, but works). this does _not_ work for unbounded * arrays because we may add rows/columns later which will expand arrays. * * so this class is an intermediate vertex that sits between the dependent edge * and all the members of the array. if a new vertex is created later, we check * existing arrays to see if anyone will need to add it. * * the more arrays you have, the more expensive these checks are (we could * probably optimize this a bit), but it only happens at create time so * potentially it's not too bad -- only on initial create and when manually * modifying the spreadsheet. * * [FIXME: that initial create step could definitely be optimized to limit checks] * */ export declare class ArrayVertex extends SpreadsheetVertexBase { static type: string; /** * this is the list of currently used array vertices. it will get cleaned * up when a vertex is no longer used (via the instance RemoveDependent * overload) and when the graph is reset (via the static Clear method). * * we could theoretically optimize this store, which might be useful if * we start using a lot of these: split by sheet ID, sort in start/end order, * and so on. */ private static list; type: string; /** the target area */ area: Area; /** * factory/lookup method: creates a vertex if it does not exist, or * returns existing vertex. returns the vertex and a flag indicating * if this was created new (true) or not (false). */ static GetVertex(area: Area): [vertex: ArrayVertex, created: boolean]; /** * this seems sloppy, does this clean up properly? */ static Clear(): void; /** * returns a list of arrays that contain this address */ static GetContainingArrays(address: ICellAddress2): ArrayVertex[]; /** * if any arrays contain this address, add edges */ static CreateImplicitEdges(vertex: Vertex, address: ICellAddress2): void; /** * constructor adds the vertex to the internal list (static to this class). * * UPDATE: use the factory method, which can check if a reference to this * area already exists. */ private constructor(); /** * override for RemoveDependent. if there are no more dependents, it will * be removed from our internal list (and hopefully GCd, but check). */ RemoveDependent(edge: Vertex): void; Calculate(graph: GraphCallbacks): void; }