-
Notifications
You must be signed in to change notification settings - Fork 4.1k
[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
Conversation
- Added a new file `find.md` documenting the `.find()` method - Included syntax, description, and a codebyte example to showcase usage
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.
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()`** |
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 **`.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 |
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 `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 |
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.
## Codebyte by example | |
## Codebyte Example |
} else { | ||
std::cout << key << " not found in the map.\n"; | ||
} | ||
}``` |
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.
}``` | |
} |
@mamtawardhani I addressed the comments you made on improving the entry. Have a look and let me know what do you think about it. |
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? |
@mamtawardhani no worries. I added one now, please have a look and let me know what do you think so far! 😃 |
- Add an ## Example block code aboce ## Codebyte Example - Add a ```shell``` output for ## Example block
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.
Looks good for a second round of review! 🚀
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.
Looks good, @dancikmad!
👋 @dancikmad 🎉 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. |
Description
Issue Solved
Type of Change
Checklist
main
branch.Issues Solved
section.