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

Iterator range #467

Merged
merged 4 commits into from
Feb 5, 2016
Merged

Iterator range #467

merged 4 commits into from
Feb 5, 2016

Conversation

chrisdembia
Copy link
Member

This PR adds a helper class that allows using range-based for loops with a pair of iterators:

std::vector<int> v {5, 10, 15, 20};
auto first = std::lower_bound(v.begin(), v.end(), 10);
auto last = std::upper_bound(v.begin(), v.end(), 15);
for (auto& x : makeIteratorRange(first, last)) {
    ...
}

* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
* *
* Portions copyright (c) 2008-16 Stanford University and the Authors. *
Copy link
Member

Choose a reason for hiding this comment

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

just 2016 here since the code is all new

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed.

@sherm1
Copy link
Member

sherm1 commented Jan 29, 2016

I like this! Thanks for making it a separate header.

P.S. You should always provide a description for your PRs. This one doesn't have one.

@sherm1
Copy link
Member

sherm1 commented Jan 30, 2016

Needs a changelog mention.

@sherm1
Copy link
Member

sherm1 commented Jan 30, 2016

Thanks for adding the description. Should it say makeIteratorRange rather than just IteratorRange?

@chrisdembia
Copy link
Member Author

Should it say makeIteratorRange rather than just IteratorRange?

Yes; I fixed it.

1. Edit changelog.
2. Add IteratorRange(std::pair<Iterator,Iterator>&)
3. Add test of IteratorRange.
@chrisdembia
Copy link
Member Author

Ready for review again.

@chrisdembia
Copy link
Member Author

Ready for review again.

@sherm1
Copy link
Member

sherm1 commented Feb 5, 2016

Beautiful -- thanks for adding the test program!

sherm1 added a commit that referenced this pull request Feb 5, 2016
@sherm1 sherm1 merged commit 5259e34 into simbody:master Feb 5, 2016
@chrisdembia chrisdembia deleted the iterator-range branch February 5, 2016 19:00
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.

None yet

2 participants