Merged PR 212: Optimize FindChildrenById from O(n) to O(1)
Optimize FindChildrenById from O(n) to O(1): - Deprecate FindContainerByIdDFS - Container: Replace Children to string[] - Add HashMap to IHistoryState that contains all containers To access a container by id now cost O(1) without any additional cost + Implement CICD for SVGLibs
This commit is contained in:
parent
466ef2b08b
commit
c256a76e01
45 changed files with 775 additions and 450 deletions
|
@ -1,7 +1,7 @@
|
|||
import { IContainerProperties } from './IContainerProperties';
|
||||
|
||||
export interface IContainerModel {
|
||||
children: IContainerModel[]
|
||||
children: string[]
|
||||
parent: IContainerModel | null
|
||||
properties: IContainerProperties
|
||||
userData: Record<string, string | number>
|
||||
|
@ -12,7 +12,7 @@ export interface IContainerModel {
|
|||
* Do not add methods since they will be lost during serialization
|
||||
*/
|
||||
export class ContainerModel implements IContainerModel {
|
||||
public children: IContainerModel[];
|
||||
public children: string[];
|
||||
public parent: IContainerModel | null;
|
||||
public properties: IContainerProperties;
|
||||
public userData: Record<string, string | number>;
|
||||
|
@ -20,7 +20,7 @@ export class ContainerModel implements IContainerModel {
|
|||
constructor(
|
||||
parent: IContainerModel | null,
|
||||
properties: IContainerProperties,
|
||||
children: IContainerModel[] = [],
|
||||
children: string[] = [],
|
||||
userData = {}) {
|
||||
this.parent = parent;
|
||||
this.properties = properties;
|
||||
|
|
|
@ -6,11 +6,12 @@ export interface IHistoryState {
|
|||
lastAction: string
|
||||
|
||||
/** Reference to the main container */
|
||||
mainContainer: IContainerModel
|
||||
mainContainer: string
|
||||
|
||||
// TODO: Add hashmap<string, IContainerModel> to optimize FincContainerById from worst O(n) to O(1)
|
||||
// TODO: this hashmap will not be serialized, modify it in the replacer and reviver in saveload.ts + worker.js
|
||||
// TODO: Update addContainers and deleteContainer to update the hashmap
|
||||
containers: Map<string, IContainerModel>
|
||||
|
||||
/** Id of the selected container */
|
||||
selectedContainerId: string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue