From 8b4725a628bae54ec0d7cb33bf9661b513dee07a Mon Sep 17 00:00:00 2001 From: mpaulson Date: Tue, 9 Aug 2022 20:01:51 -0600 Subject: [PATCH] lru here we come --- .jest.config.json | 2 +- package.json | 2 +- scripts/dsa.js | 18 ++++++++++++++++++ src/__tests__/LRU.ts | 8 ++++++++ src/global.d.ts | 5 +++++ tsconfig.json | 2 +- 6 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 src/__tests__/LRU.ts diff --git a/.jest.config.json b/.jest.config.json index e6cbbbe..9ad17ab 100644 --- a/.jest.config.json +++ b/.jest.config.json @@ -2,7 +2,7 @@ "clearMocks": true, "moduleNameMapper": { "@code/(.*)": [ - "/src/day1/$1" + "/src/day3/$1" ] }, "preset": "ts-jest" diff --git a/package.json b/package.json index 8c4c7e4..984b32e 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,6 @@ "clear": "./scripts/clear", "prettier": "prettier --write ./src", "generate": "./scripts/generate", - "day": "echo /home/mpaulson/personal/lig-machine/src/day1" + "day": "echo /home/mpaulson/personal/lig-machine/src/day3" } } \ No newline at end of file diff --git a/scripts/dsa.js b/scripts/dsa.js index bd3ef94..f491c9f 100644 --- a/scripts/dsa.js +++ b/scripts/dsa.js @@ -35,6 +35,24 @@ const list_interface = { }; module.exports = { + LRU: { + generic: "", + type: "class", + methods: [{ + name: "update", + args: "key: K, value: V", + return: "void", + }, { + name: "get", + args: "key: K", + return: "V | undefined", + }], + properties: [{ + name: "length", + type: "number", + scope: "public", + }] + }, MinHeap: { type: "class", methods: [{ diff --git a/src/__tests__/LRU.ts b/src/__tests__/LRU.ts new file mode 100644 index 0000000..3af365b --- /dev/null +++ b/src/__tests__/LRU.ts @@ -0,0 +1,8 @@ +import ArrayList from "@code/LRU"; + +test("LRU", function () { + const lru = new LRU(10); + + lru. +}); + diff --git a/src/global.d.ts b/src/global.d.ts index 330539b..e326390 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -31,3 +31,8 @@ declare type GeneralNode = { value: T; children: GeneralNode[]; }; + +declare interface ILRU { + update(key: K, value: V): void; + get(key: K): V | undefined; +} diff --git a/tsconfig.json b/tsconfig.json index 0079bd7..56dd8c6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,7 @@ "baseUrl": "src", "paths": { "@code/*": [ - "day1/*" + "day3/*" ] } },