feat: working array list
This commit is contained in:
parent
17b5708d59
commit
29de257bea
13 changed files with 29 additions and 19 deletions
|
|
@ -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>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue