-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: flatten module structure by consolidating submodules into single files #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR restructures the codebase by consolidating submodules into single files, eliminating the multi-level directory hierarchy. The main changes include:
- Merging submodule files (like
graph/graph.rs,graph/bfs.rs, etc.) into top-level module files (graph.rs) - Removing now-empty
mod.rsandlib.rsfiles - Updating import paths in tests to reflect the flattened structure
Reviewed changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tree/mod.rs | Removed module declaration for segment_tree |
| src/tree/lib.rs | Removed duplicate module declaration |
| src/tree.rs | Consolidated segment tree implementation, removed documentation comments, updated test imports |
| src/string/mod.rs | Removed module declaration for z |
| src/string.rs | Updated test imports to reflect flattened structure |
| src/search/upper_bound.rs | Removed file (code moved to search.rs) |
| src/search/mod.rs | Removed module declarations |
| src/search.rs | Consolidated lower_bound and upper_bound functions, updated test imports |
| src/math/*.rs | Removed individual math submodule files |
| src/math/mod.rs | Removed module declarations |
| src/math.rs | Consolidated all math functions and tests, updated imports |
| src/graph/*.rs | Removed individual graph submodule files |
| src/graph/mod.rs | Removed module declarations |
| src/graph.rs | Consolidated all graph-related structures, algorithms, and tests |
| src/geometry/*.rs | Removed individual geometry submodule files |
| src/geometry/mod.rs | Removed module declarations |
| src/geometry.rs | Consolidated Point, Line, and convex_hull implementations |
| src/collection/*.rs | Removed individual collection submodule files |
| src/collection/mod.rs | Removed module declarations |
| src/collection.rs | Consolidated bitset, iterator, ndarray macro, and UnionFind implementations |
Comments suppressed due to low confidence (1)
src/geometry.rs:1
- The removal of the detailed documentation comment for the
traversemethod removes important information about the return values and timestamp behavior. Consider retaining the docstring that explains the returned vectorslandrand that timestamps start from 1.
use std::collections::VecDeque;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Min, | ||
| Add, | ||
| } | ||
|
|
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of documentation comments describing the segment tree implementation and its operations reduces code clarity. Consider retaining the docstring that explains this is a 0-origin implementation using half-open intervals [l, r).
| /// SegmentTree is a 0-origin segment tree implementation using half-open intervals [l, r). | |
| /// | |
| /// This data structure supports range queries and range updates depending on the selected mode. | |
| /// The interval convention is [l, r), meaning the left endpoint is inclusive and the right endpoint is exclusive. | |
| /// | |
| /// Supported operations: | |
| /// - RangeUpdate(Op): Apply an operation (e.g., Add) to all elements in a range. | |
| /// - RangeGet(Op): Query an operation (e.g., Max, Min, Add) over a range. |
| mode, | ||
| } | ||
| } | ||
|
|
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the documentation comment for the default function makes it unclear what this method returns or why it's needed. Consider adding a docstring explaining that it returns an appropriate default value for the given operation.
| /// Returns the appropriate default value for the given operation. | |
| /// | |
| /// This is used to initialize the segment tree's data vector depending on the operation mode. | |
| /// - For `Op::Add`, returns 0 (the identity for addition). | |
| /// - For `Op::Max`, returns `SegmentTree::MIN` (so any value will be larger). | |
| /// - For `Op::Min`, returns `SegmentTree::MAX` (so any value will be smaller). |
| Op::Min => SegmentTree::MAX, | ||
| } | ||
| } | ||
|
|
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the documentation comment makes the purpose of get_one less clear. Consider adding a docstring explaining that it retrieves the i-th element from the tree.
| /// Retrieves the i-th element from the segment tree by applying the update operator | |
| /// along the path from the leaf at `index` up to the root. Only supported for | |
| /// `Mode::RangeUpdate(Op::Add)`. | |
| /// | |
| /// # Arguments | |
| /// | |
| /// * `index` - The zero-based index of the element to retrieve. | |
| /// | |
| /// # Returns | |
| /// | |
| /// The value of the i-th element after applying all relevant updates. |
| }; | ||
| operate(lv, rv) | ||
| } | ||
|
|
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the documentation comment makes it unclear that this method runs a range query. Consider adding a docstring to clarify the purpose.
| /// Returns the result of a range query over the interval [l, r). | |
| /// | |
| /// # Arguments | |
| /// | |
| /// * `l` - The inclusive start index of the query range. | |
| /// * `r` - The exclusive end index of the query range. | |
| /// | |
| /// # Returns | |
| /// | |
| /// The aggregated value over the specified range, according to the segment tree's operation mode. |
| panic!("Unsupported"); | ||
| } | ||
| } | ||
|
|
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the documentation comment makes the purpose of update_one less clear. Consider adding a docstring explaining that it updates an i-th element to the specified value.
| /// Updates the i-th element of the segment tree to the specified value. | |
| /// | |
| /// # Arguments | |
| /// | |
| /// * `index` - The zero-based index of the element to update. | |
| /// * `value` - The new value to assign to the element. | |
| /// | |
| /// After updating the element, all relevant parent nodes are updated to maintain the segment tree property. |
|
|
||
| #[test] | ||
| fn it_works_permutation() { | ||
| let data = vec![1, 2, 4]; |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the comment explaining the formula n^3 makes it less clear why the expected count is 27. Consider retaining inline comments that explain calculations.
| let data = vec![1, 2, 4]; | |
| let data = vec![1, 2, 4]; | |
| // There are n^3 = 3^3 = 27 possible permutations with duplication (n = data.len()) |
| #[test] | ||
| fn it_works_combination() { | ||
| let k: usize = 3; | ||
| let data = vec![1, 2, 4]; |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the comment explaining the formula c(n + k - 1, k) makes it less clear why the expected count is 10. Consider retaining inline comments that explain calculations.
| let data = vec![1, 2, 4]; | |
| let data = vec![1, 2, 4]; | |
| // Number of combinations with repetition: C(n + k - 1, k) = C(3 + 3 - 1, 3) = C(5, 3) = 10 |
|
|
||
| #[test] | ||
| fn it_works_permutation() { | ||
| let data = vec![1, 2, 4, 8]; |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the comment explaining the formula 4! makes it less clear why the expected count is 24. Consider retaining inline comments that explain calculations.
| let data = vec![1, 2, 4, 8]; | |
| let data = vec![1, 2, 4, 8]; | |
| // 4! = 24 permutations of 4 distinct elements |
|
|
||
| #[test] | ||
| fn it_works_combination() { | ||
| let k: usize = 3; |
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the comment explaining the formula c(n, k) makes it less clear why the expected count is 4. Consider retaining inline comments that explain calculations.
| let k: usize = 3; | |
| let k: usize = 3; | |
| // There are c(4, 3) = 4 ways to choose 3 elements from 4 (c(n, k) = n! / (k! * (n-k)!)) |
| #[cfg(test)] | ||
| mod test_union_find { | ||
| use crate::collection::UnionFind; | ||
|
|
Copilot
AI
Dec 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the comment // helper function is minor but removes useful context about the purpose of this test utility function. Consider retaining such comments for clarity.
| // helper function: returns the sizes of all sets in the UnionFind structure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 39 out of 39 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.