Skip to content
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

Find and Count for arrays #117

Closed
alvarolb opened this issue Aug 31, 2015 · 1 comment
Closed

Find and Count for arrays #117

alvarolb opened this issue Aug 31, 2015 · 1 comment

Comments

@alvarolb
Copy link

Not sure if this has been already discussed, but I find useful to implement the find and count methods also for arrays. Arrays can store multiple items, so count can be useful to check wether a item is present of how many times it appears. However I don't know if it is easy to develop taking into account that an array can store multiple value types.

@nlohmann
Copy link
Owner

nlohmann commented Dec 6, 2015

These functions could indeed be easily implemented using find (http://en.cppreference.com/w/cpp/algorithm/find) and count (http://en.cppreference.com/w/cpp/algorithm/count) from the STL's algorithms.

However, I am not sure how the find function should work for an array, because if an element is stored several times, which iterator shall be returned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants