Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

docs(contributing): fix incorrect vector iteration and simplify quick_sort example#3071

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Aditya-354 wants to merge3 commits intoTheAlgorithms:master
base:master
Choose a base branch
Loading
fromAditya-354:myBranch

Conversation

@Aditya-354
Copy link

Description of Change

This PR fixes and improves two example snippets in the "Self-test examples" section of CONTRIBUTING.md:

  1. Improved quick_sort example

    • Replaced the overly complex expression
      int(std::end(arr) - std::begin(arr)) - 1
      with the clearer and equivalentarr.size() - 1.
    • This improves readability and makes the example easier for beginners to understand.
  2. Fixed and optimized is_number_on_array example

    • The original loop usedsizeof(arr) / sizeof(int) which is incorrect for vectors and results in invalid iteration.
    • Replaced it with a safer and correct loop usingarr.size().
    • Further improved it by converting the loop to a modern range-based for-loop:
      for (constauto &x : arr) {if (x == number)returntrue;}
    • This makes the example more idiomatic, readable, and efficient.

These changes enhance correctness, clarity, make it more beginner-friendly, and implement modern C++ best practices in the contribution examples.

Checklist

  • Added description of change
  • Updated example documentation/code
  • PR title follows semantic commit guidelines
  • I acknowledge that all my contributions will be made under the project's license.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Panquesito7Panquesito7Awaiting requested review from Panquesito7Panquesito7 is a code owner

@realstealthninjarealstealthninjaAwaiting requested review from realstealthninjarealstealthninja is a code owner

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@Aditya-354

[8]ページ先頭

©2009-2025 Movatter.jp