Skip to content

Commit 8bd4b37

Browse files
♻️ refactor: Use arrow functions where possible.
1 parent 586ce4e commit 8bd4b37

21 files changed

+42
-42
lines changed

src/deletion/delete_case1.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {delete_case2} from './delete_case2.js';
88
*
99
* @param {Node} n - The input node.
1010
*/
11-
export function delete_case1(n) {
11+
export const delete_case1 = (n) => {
1212
// If n is the root, there is nothing to do: all paths go through n, and n
1313
// is black.
1414
if (n.parent !== null) delete_case2(n);
15-
}
15+
};

src/deletion/delete_case2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {delete_case4} from './delete_case4.js';
1414
*
1515
* @param {Node} n - The input node.
1616
*/
17-
export function delete_case2(n) {
17+
export const delete_case2 = (n) => {
1818
const s = sibling(n);
1919

2020
/**
@@ -38,4 +38,4 @@ export function delete_case2(n) {
3838

3939
// Otherwise, go to case 3.
4040
else delete_case3(n);
41-
}
41+
};

src/deletion/delete_case3.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {delete_case4} from './delete_case4.js';
1414
*
1515
* @param {Node} n - The input node.
1616
*/
17-
export function delete_case3(n) {
17+
export const delete_case3 = (n) => {
1818
const s = sibling(n);
1919

2020
/**
@@ -41,4 +41,4 @@ export function delete_case3(n) {
4141

4242
// Otherwise, go to case 4.
4343
else delete_case4(n);
44-
}
44+
};

src/deletion/delete_case4.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {delete_case5} from './delete_case5.js';
1414
*
1515
* @param {Node} n - The input node.
1616
*/
17-
export function delete_case4(n) {
17+
export const delete_case4 = (n) => {
1818
const s = sibling(n);
1919

2020
/**
@@ -43,4 +43,4 @@ export function delete_case4(n) {
4343

4444
// Otherwise, go to case 5.
4545
else delete_case5(n);
46-
}
46+
};

src/deletion/delete_case5.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {delete_case6} from './delete_case6.js';
1515
*
1616
* @param {Node} n - The input node.
1717
*/
18-
export function delete_case5(n) {
18+
export const delete_case5 = (n) => {
1919
const s = sibling(n);
2020

2121
// The following statements just force the red n's sibling child to be on
@@ -55,4 +55,4 @@ export function delete_case5(n) {
5555
}
5656

5757
delete_case6(n);
58-
}
58+
};

src/deletion/delete_case6.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {sibling} from '../family/sibling.js';
1414
*
1515
* @param {Node} n - The input node.
1616
*/
17-
export function delete_case6(n) {
17+
export const delete_case6 = (n) => {
1818
const s = sibling(n);
1919

2020
/**
@@ -48,4 +48,4 @@ export function delete_case6(n) {
4848
s.left.color = BLACK;
4949
rotate_right(n.parent);
5050
}
51-
}
51+
};

src/deletion/delete_one_child.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {delete_case1} from './delete_case1.js';
1212
*
1313
* @param {Node} n - The node to delete.
1414
*/
15-
export function delete_one_child(n) {
15+
export const delete_one_child = (n) => {
1616
// Precondition: n has at most one non-leaf child.
1717
// assert( n.right.isLeaf() || n.left.isLeaf());
1818

@@ -39,4 +39,4 @@ export function delete_one_child(n) {
3939
// If n is red then its child can only be black. Replacing n with its
4040
// child suffices.
4141
// }
42-
}
42+
};

src/deletion/replace_node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
* @param {Node} A - The node to replace.
55
* @param {Node} B - The replacement node.
66
*/
7-
export function replace_node(A, B) {
7+
export const replace_node = (A, B) => {
88
// Assert( A.parent !== null ) ;
99
// we never apply delete_one_child on the root so we are safe
1010

1111
if (A === A.parent.left) A.parent.left = B;
1212
else A.parent.right = B;
1313

1414
B.parent = A.parent;
15-
}
15+
};

src/family/grandparent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @param {Node} node - The input node.
55
* @returns {Node}
66
*/
7-
export function grandparent(node) {
7+
export const grandparent = (node) => {
88
// Assert((node !== null) && (node.parent !== null));
99
// We only call this function when node HAS a grandparent
1010
return node.parent.parent;
11-
}
11+
};

src/family/predecessor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* @param {Node} node - The input node.
66
* @returns {Node}
77
*/
8-
export function predecessor(node) {
8+
export const predecessor = (node) => {
99
// Assert( !node.left.isLeaf() ) ;
1010
let pred = node.left;
1111

1212
while (!pred.right.isLeaf()) pred = pred.right;
1313

1414
return pred;
15-
}
15+
};

0 commit comments

Comments
 (0)