Skip to content

Commit

Permalink
rewrite the stars hackathon
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-jonathan committed Jan 19, 2024
1 parent 567dfd5 commit 13a0d75
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 58 deletions.
14 changes: 7 additions & 7 deletions __tests__/sort/InsertionSort.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ import {
treeCreate,
} from '@/index'

type TreeNode = Tree & {
type TreeEntry = Tree & {
key: number
value: string
}

const createTreeNode = (key: number, value: string): TreeNode =>
treeCreate<TreeNode>({
const createTreeEntry = (key: number, value: string): TreeEntry =>
treeCreate<TreeEntry>({
key,
value,
})
Expand Down Expand Up @@ -199,10 +199,10 @@ describe('InsertionSort', () => {
})

it('tree sorting', () => {
const n1 = createTreeNode(1, 'a')
const n2 = createTreeNode(2, 'b')
const n3 = createTreeNode(3, 'c')
const n4 = createTreeNode(4, 'd')
const n1 = createTreeEntry(1, 'a')
const n2 = createTreeEntry(2, 'b')
const n3 = createTreeEntry(3, 'c')
const n4 = createTreeEntry(4, 'd')

const data = [
n1,
Expand Down
102 changes: 51 additions & 51 deletions __tests__/structures/Tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type A = Tree & {
value: string
}

const createTreeNode = (key: number, value: string): A =>
const createTreeEntry = (key: number, value: string): A =>
treeCreate({
key,
value,
Expand Down Expand Up @@ -101,8 +101,8 @@ describe('Tree', () => {
expect(node.size).toBe(1)
})

it('createTreeNode', () => {
const node = createTreeNode(1, 'a')
it('createTreeEntry', () => {
const node = createTreeEntry(1, 'a')

expect(guard(node, 'key', 'value')).toBeTruthy()
expect(node.parent).toBe(SentinelNode)
Expand All @@ -128,10 +128,10 @@ describe('Tree', () => {
})

it('treeInsertChild', () => {
const n1 = createTreeNode(1, 'a')
const n2 = createTreeNode(2, 'b')
const n3 = createTreeNode(3, 'c')
const n4 = createTreeNode(4, 'd')
const n1 = createTreeEntry(1, 'a')
const n2 = createTreeEntry(2, 'b')
const n3 = createTreeEntry(3, 'c')
const n4 = createTreeEntry(4, 'd')

treeInsertChild(n1, n2)
treeInsertChild(n1, n3)
Expand All @@ -145,10 +145,10 @@ describe('Tree', () => {
})

it('treeAppendChild', () => {
const n1 = createTreeNode(1, 'a')
const n2 = createTreeNode(2, 'b')
const n3 = createTreeNode(3, 'c')
const n4 = createTreeNode(4, 'd')
const n1 = createTreeEntry(1, 'a')
const n2 = createTreeEntry(2, 'b')
const n3 = createTreeEntry(3, 'c')
const n4 = createTreeEntry(4, 'd')

treeAppendChild(n1, n2)
expect(treeIsOnlyChild(n1, n2)).toBeTruthy()
Expand All @@ -166,10 +166,10 @@ describe('Tree', () => {
})

it('treeRemove', () => {
const n1 = createTreeNode(1, 'a')
const n2 = createTreeNode(2, 'b')
const n3 = createTreeNode(3, 'c')
const n4 = createTreeNode(4, 'd')
const n1 = createTreeEntry(1, 'a')
const n2 = createTreeEntry(2, 'b')
const n3 = createTreeEntry(3, 'c')
const n4 = createTreeEntry(4, 'd')

treeInsertChild(n1, n2)
treeInsertChild(n1, n3)
Expand All @@ -188,10 +188,10 @@ describe('Tree', () => {
})

it('treeInsertChildBefore', () => {
const n1 = createTreeNode(1, 'a')
const n2 = createTreeNode(2, 'b')
const n3 = createTreeNode(3, 'c')
const n4 = createTreeNode(4, 'd')
const n1 = createTreeEntry(1, 'a')
const n2 = createTreeEntry(2, 'b')
const n3 = createTreeEntry(3, 'c')
const n4 = createTreeEntry(4, 'd')

treeInsertChild(n1, n2)
treeInsertChildBefore(n1, n3, n2)
Expand All @@ -203,10 +203,10 @@ describe('Tree', () => {
})

it('treeInsertChildAfter', () => {
const n1 = createTreeNode(1, 'a')
const n2 = createTreeNode(2, 'b')
const n3 = createTreeNode(3, 'c')
const n4 = createTreeNode(4, 'd')
const n1 = createTreeEntry(1, 'a')
const n2 = createTreeEntry(2, 'b')
const n3 = createTreeEntry(3, 'c')
const n4 = createTreeEntry(4, 'd')

treeInsertChild(n1, n2)
treeInsertChildAfter(n1, n3, n2)
Expand All @@ -218,13 +218,13 @@ describe('Tree', () => {
})

it('node.size', () => {
const n1 = createTreeNode(1, 'a')
const n2 = createTreeNode(2, 'b')
const n3 = createTreeNode(3, 'c')
const n4 = createTreeNode(4, 'd')
const n5 = createTreeNode(5, 'e')
const n6 = createTreeNode(6, 'f')
const n7 = createTreeNode(7, 'g')
const n1 = createTreeEntry(1, 'a')
const n2 = createTreeEntry(2, 'b')
const n3 = createTreeEntry(3, 'c')
const n4 = createTreeEntry(4, 'd')
const n5 = createTreeEntry(5, 'e')
const n6 = createTreeEntry(6, 'f')
const n7 = createTreeEntry(7, 'g')

treeInsertChild(n1, n2)
expect(treeIsOnlyChild(n1, n2)).toBeTruthy()
Expand All @@ -244,13 +244,13 @@ describe('Tree', () => {
})

it('treeDepth', () => {
const n1 = createTreeNode(1, 'a')
const n2 = createTreeNode(2, 'b')
const n3 = createTreeNode(3, 'c')
const n4 = createTreeNode(4, 'd')
const n5 = createTreeNode(5, 'e')
const n6 = createTreeNode(6, 'f')
const n7 = createTreeNode(7, 'g')
const n1 = createTreeEntry(1, 'a')
const n2 = createTreeEntry(2, 'b')
const n3 = createTreeEntry(3, 'c')
const n4 = createTreeEntry(4, 'd')
const n5 = createTreeEntry(5, 'e')
const n6 = createTreeEntry(6, 'f')
const n7 = createTreeEntry(7, 'g')

treeInsertChild(n1, n2)
treeInsertChild(n1, n3)
Expand All @@ -269,13 +269,13 @@ describe('Tree', () => {
})

it('treeIterator', () => {
const n1 = createTreeNode(1, 'a')
const n2 = createTreeNode(2, 'b')
const n3 = createTreeNode(3, 'c')
const n4 = createTreeNode(4, 'd')
const n5 = createTreeNode(5, 'e')
const n6 = createTreeNode(6, 'f')
const n7 = createTreeNode(7, 'g')
const n1 = createTreeEntry(1, 'a')
const n2 = createTreeEntry(2, 'b')
const n3 = createTreeEntry(3, 'c')
const n4 = createTreeEntry(4, 'd')
const n5 = createTreeEntry(5, 'e')
const n6 = createTreeEntry(6, 'f')
const n7 = createTreeEntry(7, 'g')

treeAppendChild(n1, n2)
treeAppendChild(n1, n3)
Expand All @@ -294,13 +294,13 @@ describe('Tree', () => {
})

it('treeQuery', () => {
const n1 = createTreeNode(1, 'a')
const n2 = createTreeNode(2, 'b')
const n3 = createTreeNode(3, 'c')
const n4 = createTreeNode(4, 'd')
const n5 = createTreeNode(5, 'e')
const n6 = createTreeNode(6, 'f')
const n7 = createTreeNode(7, 'g')
const n1 = createTreeEntry(1, 'a')
const n2 = createTreeEntry(2, 'b')
const n3 = createTreeEntry(3, 'c')
const n4 = createTreeEntry(4, 'd')
const n5 = createTreeEntry(5, 'e')
const n6 = createTreeEntry(6, 'f')
const n7 = createTreeEntry(7, 'g')

treeAppendChild(n1, n2)
treeAppendChild(n1, n3)
Expand Down

0 comments on commit 13a0d75

Please sign in to comment.