Jump to content
  • Advertisement
Sign in to follow this  
Washu

Ranges

This topic is 5469 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Saw this article in CUJ: "Ranges: Concepts and Implementation" and I was wondering what anyone else thought about the idea. If you aren't familiar with what a range is, you can go here: STLSoft Integral Range and see an example of one. "Ranges are a complimentary concept to Iterators, aimed at manipulation of collections as a whole, and are both easier to use and provide a more comprehensive abstraction of collections."

Share this post


Link to post
Share on other sites
Advertisement
I think ranges are a great tool. In fact, python has had the range function since the beginning, I believe.



for i in range(10):
print i


Share this post


Link to post
Share on other sites
That's the fundamental concept/object in Excel (Range).

"...manipulation of collections as a whole..." doesn't seem right though - the whole idea is a delineated (non-proper) subset of the collection.

Ug, I don't like thier implementation. It appears they are creating new containers that follow thier 'range' concept.


In my mind std::pair<iterator,iterator> is a range and then you can cleanly overload the existing algorithms.

template<typename RAI>
iterator_traits<RAI>::difference_type distance(std::pair<RAI,RAI>& range)
{
return range.second - range.first;
}

Share this post


Link to post
Share on other sites
Quote:
Original post by Magmai Kai Holmlor
That's the fundamental concept/object in Excel (Range).

"...manipulation of collections as a whole..." doesn't seem right though - the whole idea is a delineated (non-proper) subset of the collection.

Ug, I don't like thier implementation. It appears they are creating new containers that follow thier 'range' concept.


In my mind std::pair<iterator,iterator> is a range and then you can cleanly overload the existing algorithms.

template<typename RAI>
iterator_traits<RAI>::difference_type distance(std::pair<RAI,RAI>& range)
{
return range.second - range.first;
}

Yes, i'm not a fan of their range implementation.
I see a range more as a way of addressing a set of elements within a container. Something like being able to use policies with a range would be nice, for instance: having a container of values, then being able to associate a predicate with the range so that it will only return values from the container that match the predicate (in a linear fashion, from the starting iterator to the ending iterator of the container). This would allow you to iterate over those values as though they were a contiguous set.

Share this post


Link to post
Share on other sites
I haven't seen the article yet. How is it different from using bounding iterators and adding features to skip every x members of the collection?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!