diff --git a/__tests__/structures/Tree.spec.ts b/__tests__/structures/Tree.spec.ts index 2d6452f..428bac9 100644 --- a/__tests__/structures/Tree.spec.ts +++ b/__tests__/structures/Tree.spec.ts @@ -137,10 +137,10 @@ describe('Tree', () => { treeInsertChild(n1, n3) treeInsertChild(n1, n4) - expect(treeIsFirstChild(n2, n1)).toBeFalsy() - expect(treeIsFirstChild(n3, n1)).toBeFalsy() - expect(treeIsFirstChild(n4, n1)).toBeTruthy() - expect(treeIsLastChild(n2, n1)).toBeTruthy() + expect(treeIsFirstChild(n1, n2)).toBeFalsy() + expect(treeIsFirstChild(n1, n3)).toBeFalsy() + expect(treeIsFirstChild(n1, n4)).toBeTruthy() + expect(treeIsLastChild(n1, n2)).toBeTruthy() expect(n1.size).toBe(4) }) @@ -151,17 +151,17 @@ describe('Tree', () => { const n4 = createTreeNode(4, 'd') treeAppendChild(n1, n2) - expect(treeIsOnlyChild(n2, n1)).toBeTruthy() + expect(treeIsOnlyChild(n1, n2)).toBeTruthy() treeAppendChild(n1, n3) - expect(treeIsOnlyChild(n2, n1)).toBeFalsy() + expect(treeIsOnlyChild(n1, n2)).toBeFalsy() treeAppendChild(n1, n4) - expect(treeIsLastChild(n2, n1)).toBeFalsy() - expect(treeIsLastChild(n3, n1)).toBeFalsy() - expect(treeIsLastChild(n4, n1)).toBeTruthy() - expect(treeIsFirstChild(n2, n1)).toBeTruthy() + expect(treeIsLastChild(n1, n2)).toBeFalsy() + expect(treeIsLastChild(n1, n3)).toBeFalsy() + expect(treeIsLastChild(n1, n4)).toBeTruthy() + expect(treeIsFirstChild(n1, n2)).toBeTruthy() expect(n1.size).toBe(4) }) @@ -227,10 +227,10 @@ describe('Tree', () => { const n7 = createTreeNode(7, 'g') treeInsertChild(n1, n2) - expect(treeIsOnlyChild(n2, n1)).toBeTruthy() + expect(treeIsOnlyChild(n1, n2)).toBeTruthy() treeInsertChild(n1, n3) - expect(treeIsOnlyChild(n3, n1)).toBeFalsy() + expect(treeIsOnlyChild(n1, n3)).toBeFalsy() treeInsertChild(n1, n4) treeInsertChild(n1, n5) diff --git a/package-lock.json b/package-lock.json index 026b6aa..3d720be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cosmicmind/algojs", - "version": "0.0.1-rc-102823-2-c", + "version": "0.0.1-rc-102823-2-d", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@cosmicmind/algojs", - "version": "0.0.1-rc-102823-2-c", + "version": "0.0.1-rc-102823-2-d", "license": "BSD-3-Clause", "dependencies": { "@cosmicmind/foundationjs": "^0.0.1-rc-092723-1" diff --git a/package.json b/package.json index 5b6a0d0..e50f722 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cosmicmind/algojs", - "version": "0.0.1-rc-102823-2-c", + "version": "0.0.1-rc-102823-2-d", "description": "An algorithms and data structures library in TypeScript.", "keywords": [], "author": { diff --git a/src/structures/Tree.ts b/src/structures/Tree.ts index 5195d28..c7c52b9 100644 --- a/src/structures/Tree.ts +++ b/src/structures/Tree.ts @@ -155,21 +155,21 @@ export function treeIsChild(parent: T, node: T, compare = TreeCo /** * @performance O(1) */ -export function treeIsFirstChild(node: T, parent: T, compare = TreeCompareFn): boolean { +export function treeIsFirstChild(parent: T, node: T, compare = TreeCompareFn): boolean { return listIsFirst(parent.children as List, node, compare) } /** * @performance O(1) */ -export function treeIsLastChild(node: T, parent: T, compare = TreeCompareFn): boolean { +export function treeIsLastChild(parent: T, node: T, compare = TreeCompareFn): boolean { return listIsLast(parent.children as List, node, compare) } /** * @performance O(1) */ -export function treeIsOnlyChild(node: T, parent: T, compare = TreeCompareFn): boolean { +export function treeIsOnlyChild(parent: T, node: T, compare = TreeCompareFn): boolean { return listIsFirst(parent.children as List, node, compare) && listIsLast(parent.children as List, node, compare) }