Skip to content

Conversation

@djeada
Copy link
Owner

@djeada djeada commented Sep 18, 2025

No description provided.

@djeada djeada requested a review from Copilot September 18, 2025 11:07
Copy link
Contributor

Copilot AI left a 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 refactors duplicate counting functions and tests by introducing a new O(n) set-based counting function and creating a generic test framework to reduce code duplication.

  • Added a new countDuplicatesSet function using unordered sets for O(n) performance
  • Replaced individual test functions with a generic runTests template function
  • Added utility functions for vector string conversion and improved test output formatting

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

for (size_t i = 0; i < expected.size(); ++i) {
std::cout << expected[i] << (i+1<expected.size()? ",":"");
// normalize for comparison if vector
if constexpr (std::is_same_v<decltype(got), std::vector<int>>) {
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded std::vector<int> type check makes this template less generic. Consider using a type trait or concept to check if the type is a container that supports sorting, making the template more reusable for other vector types.

Copilot uses AI. Check for mistakes.
countDuplicatesSet,
[](auto& tc){ return tc.expectedCount; },
[](auto v){ return std::to_string(v); }
);
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Missing blank line after the closing parenthesis for consistency with the formatting pattern used in other runTests calls (compare with lines 169, 185).

Suggested change
);
);

Copilot uses AI. Check for mistakes.
@djeada djeada merged commit fe55bf6 into master Sep 18, 2025
2 checks passed
@djeada djeada deleted the djeada-patch-3 branch September 20, 2025 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant