Skip to content
Artavazd Barseghyan edited this page May 31, 2013 · 3 revisions

A class used to describe a portion of a series.

Properties

//the start index (0 is the first)
unsigned int location;

//the number of items in the range (can be 0)
unsigned int length;

Instance methods

//set range values
void setRange(unsigned int loc, unsigned int len);

//returns a boolean value that indicates whether the range is equal to the given range
bool equals(const CCRange& target);

//returns the intersection of the range with the specified range
//that is, a range containing the indices that exist in both ranges
CCRange intersectionRange(const CCRange&  other);

//returns the union of the range with the specified range
//if one range is completely contained in the other, the returned range is equal to the larger range
CCRange unionRange(const CCRange&  other);

//returns a boolean value that indicates whether a specified position is in the range
bool containsLocation(unsigned int loc);

//returns the sum of the location and length of the range
unsigned int max();

//description of the range
const char* description();

Example

CCRange range1(1, 5);
CCRange range2(2, 7);

//the resulting range will start at 2 and have a length of 4
CCRange resRange = range1.intersectionRange(range2);

//the resulting range will start at 1 and have a length of 8
resRange = range1.unionRange(range2);