New extension: CCRange

New extension: CCRange
0.0 0


Hello everybody,

Today I’m bringing you another extension, CCRange.
You can use it for creating ranges, similar to NSRange of Foundation Framework, but in object oriented way.

Note: read wiki for documentation.



I’ve just took a quick look at it, but it would have sense to be able to iterate a range, right? (like in python). A macro for it and iterators (for C++11 range based loops) would be good for it :slight_smile:


I’ve never used ranges in that way, can you give me some examples please?
I have only used ranges for storing location and length of series of data, for example strings or arrays.
Thank you


Let r be a CCRange with location 0 and length 3.

Iterating r would mean to be able to do something with 0, 1 and 2.


for (unsigned int i = location; i < location + length; i++)
    // do something with i

This could be done with a macro:

unsigned int i;

    // do something

Or with C++11 iterators:

for (unsigned int i : r)
    // do something