feat: working array list
This commit is contained in:
parent
17b5708d59
commit
29de257bea
13 changed files with 29 additions and 19 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,3 +1,6 @@
|
|||
node_modules
|
||||
src/day*
|
||||
./ligma.config.js
|
||||
dist
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"clearMocks": true,
|
||||
"moduleNameMapper": {
|
||||
"@code/(.*)": [
|
||||
"<rootDir>/src/day6/$1"
|
||||
"<rootDir>/src/day10/$1"
|
||||
]
|
||||
},
|
||||
"preset": "ts-jest"
|
||||
|
|
|
|||
|
|
@ -13,9 +13,13 @@
|
|||
"typescript": "^4.7.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest ArrayList"
|
||||
"test": "jest ArrayList",
|
||||
"clear": "./scripts/clear",
|
||||
"generate": "./scripts/generate",
|
||||
"start": "echo vim /home/mpaulson/personal/kata/src/day9",
|
||||
"day": "echo /home/mpaulson/personal/kata/src/day10"
|
||||
},
|
||||
"kata_stats": {
|
||||
"ArrayList": 4
|
||||
"ArrayList": 8
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
module.exports.package_json = function(config) {
|
||||
module.exports.package_json = function(config, day_path) {
|
||||
const package_json = require("../package.json");
|
||||
package_json.scripts.test = `jest ${config.dsa.join(" ")}`;
|
||||
package_json.scripts.day = `echo ${day_path}`;
|
||||
|
||||
package_json.kata_stats = config.dsa.reduce((acc, ds) => {
|
||||
if (!acc[ds]) {
|
||||
|
|
@ -13,6 +14,7 @@ module.exports.package_json = function(config) {
|
|||
return acc;
|
||||
}, package_json.kata_stats || {});
|
||||
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, "..", "package.json"),
|
||||
JSON.stringify(package_json, null, 4));
|
||||
|
|
|
|||
|
|
@ -55,5 +55,5 @@ config.dsa.forEach(ds => {
|
|||
const align = require("./align-configs");
|
||||
align.jest(day_name);
|
||||
align.ts_config(day_name);
|
||||
align.package_json(config, day_name);
|
||||
align.package_json(config, day_path);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import ArrayList from "@code/array-list";
|
||||
import ArrayList from "@code/ArrayList";
|
||||
|
||||
test("array-list", function() {
|
||||
const list = new ArrayList<number>(3);
|
||||
|
|
@ -7,14 +7,15 @@ test("array-list", function() {
|
|||
list.add(7);
|
||||
list.add(9);
|
||||
|
||||
expect(list.remove()).toEqual(5);
|
||||
expect(list.get(2)).toEqual(9);
|
||||
expect(list.removeAt(1)).toEqual(7);
|
||||
expect(list.length).toEqual(2);
|
||||
|
||||
list.add(11);
|
||||
expect(list.remove()).toEqual(7);
|
||||
expect(list.remove()).toEqual(9);
|
||||
expect(list.remove()).toEqual(11);
|
||||
expect(list.remove()).toEqual(undefined);
|
||||
expect(list.removeAt(1)).toEqual(9);
|
||||
expect(list.remove(9)).toEqual(undefined);
|
||||
expect(list.removeAt(0)).toEqual(5);
|
||||
expect(list.removeAt(0)).toEqual(11);
|
||||
expect(list.length).toEqual(0);
|
||||
|
||||
list.add(5);
|
||||
|
|
@ -26,7 +27,7 @@ test("array-list", function() {
|
|||
|
||||
list.add(11);
|
||||
list.add(13);
|
||||
expect(list.length).toEqual(5);
|
||||
expect(list.length).toEqual(4);
|
||||
expect(list.capacity).toEqual(6);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import LinkedList from "@code/doubly-linked-list";
|
||||
import LinkedList from "@code/DoublyLinkedList";
|
||||
|
||||
test("linked-list", function() {
|
||||
const list = new LinkedList<number>();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import insertion_sort from "@code/insertion-sort";
|
||||
import insertion_sort from "@code/InsertionSort";
|
||||
|
||||
test("insertion-sort", function() {
|
||||
const arr = [9, 3, 7, 4, 69, 420, 42];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import merge_sort from "@code/merge-sort";
|
||||
import merge_sort from "@code/MergeSort";
|
||||
|
||||
test("merge-sort", function() {
|
||||
const arr = [9, 3, 7, 4, 69, 420, 42];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import Queue from "@code/queue";
|
||||
import Queue from "@code/Queue";
|
||||
|
||||
test("queue", function() {
|
||||
const list = new Queue<number>();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import LinkedList from "@code/single-linked-list";
|
||||
import LinkedList from "@code/SingleLinkedList";
|
||||
|
||||
test("linked-list", function() {
|
||||
const list = new LinkedList<number>();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import Stack from "@code/stack";
|
||||
import Stack from "@code/Stack";
|
||||
|
||||
test("queue", function() {
|
||||
const list = new Stack<number>();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
"baseUrl": "src",
|
||||
"paths": {
|
||||
"@code/*": [
|
||||
"day6/*"
|
||||
"day10/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue