You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where former takes input as streams and uses configured reader/writer factories to construct `DataReader` for input and `DataWriter` for output; and latter just uses pre-constructed instances.
35
37
36
38
In addition to core sorting functionality, `Sorter` instance also gives access to progress information (it implements `SortingState` interface with accessor methods).
37
39
38
40
A very simple example of sorting a text file using line-by-line comparison is:
39
41
40
-
TextSorter sorter = new TextFileSorter(new SortConfig().withMaxMemoryUsage(20 * 1000 * 1000));
which would read text from file "input.txt", sort using about 20 megs of heap (note: estimates for memory usage are rough), use temporary files if necessary (i.e. for small files it's just in-memoryu sort, for bigger real merge sort), and write output as file "output.txt".
45
48
46
49
## Command-line utility
47
50
48
51
Project jar is packaged such that it can be used as a primitive 'sort' tool like so:
49
52
50
-
java -jar java-merge-sort-0.9.1.jar [input-file]
53
+
```java
54
+
java -jar java-merge-sort-1.0.0.jar [input-file]
55
+
```
51
56
52
57
where sorted output gets printed to `stdout`; and argument is optional (if missing, reads input from stdout).
53
58
(implementation note: this uses standard `TextFileSorter` mentioned above)
0 commit comments