# 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.

## 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 on other sites
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 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 on other sites
Quote:
 Original post by Magmai Kai HolmlorThat'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 is a range and then you can cleanly overload the existing algorithms.templateiterator_traits::difference_type distance(std::pair& 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 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?

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 18
• 13
• 14
• 43
• 63