EDRange


Inherits From:
EDIRCObject
Conforms To:
NSCopying
NSCoding
Declared In:
EDRange.h


Class Description

Range objects provide an object-oriented wrapper around NSSRanges; especially useful when you want to store them in collections.


Instance Variables

NSRange range;

rangeThe corresponding NSRange.


Method Types

Creating new range objects
+ rangeWithLocation:length:
+ rangeWithLocations::
+ rangeWithRangeValue:
- initWithRangeValue:
- initWithLocation:length:
- initWithLocations::
Retrieving elements
- location
- length
- endLocation
- rangeValue
"Contains" tests
- isLocationInRange:
- containsRange:
Comparing ranges
- isEqualToRange:
- compareLocation:
Combining ranges
- intersectionRange:
- unionRange:


Class Methods

rangeWithLocation:length:

+ (id)rangeWithLocation:(unsigned int)loc length:(unsigned int)len

Creates and returns a range object with starting at loc and ranging len indices.


rangeWithLocations::

+ (id)rangeWithLocations:(unsigned int)startLoc :(unsigned int)endLoc

Creates and returns a range object with starting at startLoc and ending at endLoc.


rangeWithRangeValue:

+ (id)rangeWithRangeValue:(NSRange)aRangeValue

Creates and returns a range object for the NSRange aRangeValue.


Instance Methods

compareLocation:

- (NSComparisonResult)compareLocation:(EDRange *)otherRange

Returns NSOrderedAscending if the start location of the receiver is greater than the one of otherRange, NSOrderedSame if both have the same start location and NSOrderedDescending otherwise.


containsRange:

- (BOOL)containsRange:(EDRange *)otherRange

Returns YES if otherRange is fully contained in the receiver, i.e. the union of both is equivalent to the receiver.


endLocation

- (unsigned int)endLocation

Returns the end location of the range, i.e. startLocation + length - 1.


initWithLocation:length:

- (id)initWithLocation:(unsigned int)loc length:(unsigned int)len

Initialises a newly allocated range by setting its starting location to loc and its range to len.


initWithLocations::

- (id)initWithLocations:(unsigned int)startLoc :(unsigned int)endLoc

Initialises a newly allocated range by setting its starting location to startLoc and its end location to endLoc.


initWithRangeValue:

- (id)initWithRangeValue:(NSRange)aRangeValue

Initialises a newly allocated range with the NSRange aRangeValue.


intersectionRange:

- (EDRange *)intersectionRange:(EDRange *)otherRange

Returns a range object describing the intersection of the receiver and otherRange, i.e. a range containing the indices that exist in both ranges, nil if the intersection is empty.


isEqualToRange:

- (BOOL)isEqualToRange:(EDRange *)otherRange

Returns YES if otherRange is equivalent to the receiver, NO otherwise. When you know both objects are ranges, this method is a faster way to check equality than isEqual:.


isLocationInRange:

- (BOOL)isLocationInRange:(unsigned int)index

Returns YES if index is in the range, i.e. startLocation <= index <= endLocation.


length

- (unsigned int)length

Returns the length of the range.


location

- (unsigned int)location

Returns the (start) location of the range.


rangeValue

- (NSRange)rangeValue

Returns the corresponding NSRange.


unionRange:

- (EDRange *)unionRange:(EDRange *)otherRange

Returns a range object describing the union of the receiver and otherRange, i.e. a range containing the indices in and between both ranges.


Version 2.0 Copyright ©2002. All Rights Reserved.