Skip to content

Commit a0a45dd

Browse files
authored
Update README.md
1 parent c6918a8 commit a0a45dd

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

challenges/wc-command/README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,44 @@
11
# wc-command
2+
**Author:** [namvdo](https://github.com/namvdo)
3+
## Overview
24

3-
## Given By
5+
`wc-command` is a program that implements a simple command-line utility for counting words in a text file and the occurrences of a specific word. The program is designed to leverage parallel processing for improved performance, making it suitable for handling large text files efficiently.
46

5-
## Topics
7+
## Features
8+
9+
- Count the total number of words in a text file.
10+
- Count the occurrences of a specified word in a text file.
11+
12+
## Relevant Background Knowledge
13+
To effectively tackle this problem, it is important to have a basic understanding of the following concepts:
14+
1. **Rust Syntax**: Familiarity with Rust's syntax, including functions, control flow, and data structures.
15+
2. **Ownership and Borrowing**: Understanding Rust’s ownership model is crucial for memory safety and efficient resource management.
16+
3. **Parallel Processing**: Knowledge of threading in Rust to leverage concurrency for performance improvements.
17+
4. **Memory Mapping**: Skills in using memory-mapped files for efficient file reading.
18+
5. **Command-Line Arguments**: Understanding how to parse command-line arguments for user input.
619

720
## Main Functions
821

9-
## Example Output
22+
1. **`read_file_as_string(file_path: &str) -> String`**
23+
Reads a file and returns its content as a `String`.
1024

11-
## Usage Example
25+
2. **`count_words(text: &str) -> usize`**
26+
Counts the total number of words in the provided text.
1227

28+
3. **`count_word_occurrences(text: &str, word: String) -> usize`**
29+
Counts the occurrences of a specific word in the provided text.
30+
31+
4. **`count_in_paralell<F>(text: &str, count_fn: F) -> usize`**
32+
A generic function that processes text in parallel using the provided counting function.
33+
34+
## Usage Example
35+
First, compile the program:
36+
```bash
37+
cd challenges/wc-command && cargo build
38+
cargo run -- rccwc -w /path/to/the/input/file.txt
39+
cargo run -- rccwc -wo rust /path/to/the/input/file.txt
40+
```
41+
Run test test:
42+
```bash
43+
cargo test
44+
```

0 commit comments

Comments
 (0)