**Inherits From:**
- NSObject

**Conforms To:**
- NSCopying
- NSCoding

**Declared In:**
- EDNumberSet.h

## Class Description

**EDNumberSet** is a data structure that stores large sets of numbers efficiently. (**NSSet** with instances of **NSNumber** might be a tad inefficient when you reach a couple of thousand numbers.) As an addeded bonus it also provides operations dealing with ranges that are covered, i.e. all numbers inbetween a a start and an end number are also in the set. The set {7,3,8,9,2} covers two ranges, namely [2..3] and [7..9]. All operations are efficient in that they run in O(lg *n*) or less.

## Instance Variables

`EDSortedArray *`**rangeArray**;

rangeArray | All instance variables are private. |

## Method Types

Creating number sets
- - init
- - initWithNumbersInRange:
- - initWithRanges:

Adding/removing numbers
- - addNumber:
- - removeNumber:
- - addNumbersInRange:
- - removeNumbersInRange:

Checking individual numbers
- - containsNumber:
- - lowestNumber
- - highestNumber

Checking ranges
- - coveredRanges
- - coveredRangeEnumerator
- - coveredRangesInRange:
- - uncoveredRangesInRange:

## Instance Methods

`- (void)`**addNumber:**(NSNumber *)*aNumber*

Adds *aNumber* to the set. The number object itself is not neccessarily used and retained.

`- (void)`**addNumbersInRange:**(EDRange *)*aRange*

Adds all numbers in *aRange* to the set.

`- (BOOL)`**containsNumber:**(NSNumber *)*aNumber*

Returns YES if *number* is in the set, NO otherwise.

`- (NSEnumerator *)`**coveredRangeEnumerator**

Returns an enumerator for all EDRange objects for all ranges covered by the numbers in the set.

`- (NSArray *)`**coveredRanges**

Returns an array containing EDRange objects for all ranges covered by the numbers in the set.

`- (NSArray *)`**coveredRangesInRange:**(EDRange *)*aRange*

Returns an array containing EDRange objects for all ranges covered by the numbers in the set within *aRange*.

`- (NSNumber *)`**highestNumber**

Returns the highest number in the set.

`- (id)`**init**

Initialises a newly allocated number set.

`- (id)`**initWithNumbersInRange:**(EDRange *)*aRange*

Initialises a newly allocated number set by adding all numbers in *aRange* to it.

`- (id)`**initWithRanges:**(NSArray *)*rangeList*

Initialises a newly allocated number set by adding all numbers in the ranges in *rangeList* to it.

`- (NSNumber *)`**lowestNumber**

Returns the lowest number in the set.

`- (void)`**removeNumber:**(NSNumber *)*aNumber*

Removes *aNumber* from the set.

`- (void)`**removeNumbersInRange:**(EDRange *)*aRange*

Removes all numbers in *aRange* from the set.

`- (NSArray *)`**uncoveredRangesInRange:**(EDRange *)*aRange*

Returns an array containing EDRange objects for all ranges not covered by the numbers in the set within *aRange*.

Version 2.1 Copyright ©2003. All Rights Reserved.