Skip to content

[Term Entry] C++ Maps: .find() #6386

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

Merged
merged 21 commits into from
Mar 27, 2025
Merged

Conversation

dancikmad
Copy link
Contributor

@dancikmad dancikmad commented Mar 22, 2025

Description

Issue Solved

Type of Change

  • Adding a new entry

Checklist

  • All writings are my own.
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

@dancikmad dancikmad mentioned this pull request Mar 22, 2025
3 tasks
@mamtawardhani mamtawardhani self-assigned this Mar 23, 2025
@mamtawardhani mamtawardhani added c++ C++ entries new entry New entry or entries status: under review Issue or PR is currently being reviewed labels Mar 23, 2025
Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

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

Hey @dancikmad, thank you for contributing to Codecademy Docs, the entry is nicely written! 😄

I've suggested a few changes, could you please review and modify those at your earliest convenience? Thank you! 😃

- 'paths/computer-science'
---

The **`.find()`** method looks for an element with a given key in a map. It returns an iterator pointing to the element if the key is found; otherwise, it returns an iterator pointing to **`map.end()`**
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
The **`.find()`** method looks for an element with a given key in a map. It returns an iterator pointing to the element if the key is found; otherwise, it returns an iterator pointing to **`map.end()`**
The **`.find()`** method searches for an element with a given key in a `std::map`. If found, it returns an iterator to the element; otherwise, it returns an iterator to `map.end()`.

mapName.find(key);
```

The `key` is the element to be searched
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
The `key` is the element to be searched
**Parameters:**
- `key`: The key to search for in the map.
**Return value:**
- If the key is found, returns an iterator pointing to the key-value pair.
- If the key is not found, returns an iterator to `map.end()`.


The `key` is the element to be searched

## Codebyte by example
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
## Codebyte by example
## Codebyte Example

} else {
std::cout << key << " not found in the map.\n";
}
}```
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
}```
}

@dancikmad
Copy link
Contributor Author

@mamtawardhani I addressed the comments you made on improving the entry. Have a look and let me know what do you think about it.

@mamtawardhani
Copy link
Collaborator

Hey @dancikmad, thank you for making the suggested changes. Could you also please add an ## Example block above the ## Codebyte Example block, which demonstrates the term explained?
Thanks 😄

@dancikmad
Copy link
Contributor Author

@mamtawardhani no worries. I added one now, please have a look and let me know what do you think so far! 😃

dancikmad and others added 2 commits March 26, 2025 02:13
- Add an ## Example block code aboce ## Codebyte Example

- Add a ```shell``` output for ## Example block
Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

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

Looks good for a second round of review! 🚀

Copy link
Collaborator

@Sriparno08 Sriparno08 left a comment

Choose a reason for hiding this comment

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

Looks good, @dancikmad!

@Sriparno08 Sriparno08 merged commit b3aea5d into Codecademy:main Mar 27, 2025
7 checks passed
Copy link

👋 @dancikmad
You have contributed to Codecademy Docs, and we would like to know more about you and your experience.
Please take a minute to fill out this four question survey to help us better understand Docs contributions and how we can improve the experience for you and our learners.
Thank you for your help!

🎉 Your contribution(s) can be seen here:

https://www.codecademy.com/resources/docs/cpp/maps/find

Please note it may take a little while for changes to become visible.
If you're appearing as anonymous and want to be credited, visit the linked accounts page and ensure that your GitHub account is linked.

@Sriparno08 Sriparno08 added status: review 2️⃣ completed and removed status: under review Issue or PR is currently being reviewed labels Mar 27, 2025
@dancikmad dancikmad deleted the cpp-map-find branch March 27, 2025 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Term Entry] C++ Maps: .find()
3 participants