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:
Eric Nguyen 2022-10-12 09:39:54 +00:00
parent 466ef2b08b
commit c256a76e01
45 changed files with 775 additions and 450 deletions

View file

@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { describe, it, expect } from 'vitest';
import { API_FETCH_URL } from '../../../public/svgld-settings';
import { AddMethod } from '../../Enums/AddMethod';
import { Orientation } from '../../Enums/Orientation';
import { Position } from '../../Enums/Position';
@ -10,7 +11,6 @@ import { IAvailableSymbol } from '../../Interfaces/IAvailableSymbol';
import { ICategory } from '../../Interfaces/ICategory';
import { IConfiguration } from '../../Interfaces/IConfiguration';
import { IContainerModel, ContainerModel } from '../../Interfaces/IContainerModel';
import { IEditorState } from '../../Interfaces/IEditorState';
import { IHistoryState } from '../../Interfaces/IHistoryState';
import { IPattern } from '../../Interfaces/IPattern';
import { DEFAULT_MAINCONTAINER_PROPS, GetDefaultContainerProps } from '../../utils/default';
@ -21,9 +21,9 @@ const CHARP_WEB_API_RESOURCE_URL = 'SVGLD';
const CSHARP_WEB_API_URL = CSHARP_WEB_API_BASE_URL + CHARP_WEB_API_RESOURCE_URL + '/';
// TODO: Migrate this test to SVGLDWebAPI rather than using test-server/
describe.concurrent('Test server test', () => {
describe.concurrent('Test server test', async() => {
it('Load environment', () => {
const url = import.meta.env.VITE_API_FETCH_URL;
const url = API_FETCH_URL;
expect(url).toBe('http://localhost:5000');
});
@ -103,9 +103,11 @@ describe.concurrent('Models test suite', () => {
DEFAULT_MAINCONTAINER_PROPS
);
const containers = new Map<string, IContainerModel>();
const historyState: IHistoryState = {
lastAction: 'string',
mainContainer,
mainContainer: mainContainer.properties.id,
containers,
selectedContainerId: '3',
typeCounters: {
main: 1