Skip to content

Commit 0befb1d

Browse files
author
Isaac Ramirez
committed
- update multiway client to match new template
1 parent 5c5604b commit 0befb1d

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/adts/index-min-priority-queue/multiway.client.js

+17-16
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,25 @@ const { StdOut, In } = require('../../libs')
1010
* @see [edu.princeton.cs.algs4.Multiway.java]{@link https://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/Multiway.java.html}
1111
*/
1212
class Multiway {
13+
/**
14+
* Creates `n` streams `In` for each given file path
15+
* that contains an ordered sequence of chars,
16+
* then it merges all of them in sorted order.
17+
* @example <caption>Merging 3 sorted source files</caption>
18+
* {@lang bash}
19+
* $ ./client Multiway algs4-data/m1.txt algs4-data/m2.txt algs4-data/m3.txt
20+
* A A B B B C D E F F G H I I J N P Q Q Z
21+
* @param {...string} args - The file paths: `['path/1', 'path/2', ..., 'path/n']`
22+
*/
23+
static main (args) {
24+
const streams = args.map(file => new In(file))
25+
26+
this.merge(streams)
27+
}
28+
1329
/**
1430
* Given some ordered streams, it merges all of them
15-
* in order printing out the sequence in the `StdOut`.
31+
* in order, printing out the sequence in the `StdOut`.
1632
* @param {Array<In>} streams - The array of `In` streams.
1733
*/
1834
static merge (streams) {
@@ -35,21 +51,6 @@ class Multiway {
3551
}
3652
}
3753
}
38-
39-
/**
40-
* Creates n `In` streams depending on the given file paths,
41-
* then it merges them in sorted order.
42-
* @param {...string} args - The file paths.
43-
* @example <caption>Merging 3 sorted source files</caption>
44-
* {@lang bash}
45-
* $ ./client Multiway algs4-data/m1.txt algs4-data/m2.txt algs4-data/m3.txt
46-
* A A B B B C D E F F G H I I J N P Q Q Z
47-
*/
48-
static main (args) {
49-
const streams = args.map(file => new In(file))
50-
51-
this.merge(streams)
52-
}
5354
}
5455

5556
module.exports = { Multiway }

0 commit comments

Comments
 (0)