Class CPIndexSet

CPObject
    extended byCPIndexSet
Direct Known Subclasses:
CPMutableIndexSet

@implementation CPIndexSet : CPObject

Instances of this class are collections of numbers. Each integer can appear in a collection only once.


Method Summary
+(id)indexSet
          Returns a new empty index set.
+(id)indexSetWithIndex:(int)anIndex
          Returns a new index set with just one index.
+(id)indexSetWithIndexesInRange:(CPRange)aRange
          Returns a new index set with all the numbers in the specified range.
-(id)init
          Initializes the receiver.
-(id)initWithCoder:(CPCoder)aCoder
          Initializes the index set from a coder.
-(id)initWithIndex:(int)anIndex
          Initializes the index set with a single index.
-(id)initWithIndexSet:(CPIndexSet)anIndexSet
          Initializes the index set with another index set.
-(id)initWithIndexesInRange:(CPRange)aRange
          Initializes the index set with numbers from the specified range.
-(void)addIndex:(unsigned)anIndex
          Adds an index to the set.
-(void)addIndexes:(CPIndexSet)anIndexSet
          Adds indices to the set.
-(void)addIndexesInRange:(CPRange)aRange
          Adds the range of indices to the set.
-(BOOL)containsIndex:(unsigned)anIndex
          Returns YES if the index set contains the specified index.
-(BOOL)containsIndexes:(CPIndexSet)anIndexSet
          Returns YES if the receving index set contains all the indices in the argument.
-(BOOL)containsIndexesInRange:(CPRange)aRange
          Returns YES if the index set contains all the numbers in the specified range.
-(id)copy
          Creates a deep copy of the index set.
-(int)count
          The number of indices in the set.
-(CPString)description
          Returns a human readable string describing the receiver.
-(void)encodeWithCoder:(CPCoder)aCoder
          Writes out the index set to the specified coder.
-(int)firstIndex
          Return the first index in the set.
-(unsigned)getIndexes:(CPArray)anArray maxCount:(unsigned)aMaxCount inIndexRange:(CPRange)aRangePointer
          Fills up the specified array with numbers from the index set within the specified range.
-(unsigned)indexGreaterThanIndex:(unsigned)anIndex
          Returns the first index value in the receiver which is greater than anIndex.
-(unsigned int)indexGreaterThanOrEqualToIndex:(unsigned)anIndex
          Returns the first index value in the receiver which is greater than or equal to anIndex.
-(unsigned)indexLessThanIndex:(unsigned)anIndex
          Returns the first index value in the receiver which is less than anIndex.
-(unsigned int)indexLessThanOrEqualToIndex:(unsigned)anIndex
          Returns the first index value in the receiver which is less than or equal to anIndex.
-(BOOL)intersectsIndexesInRange:(CPRange)aRange
          Checks if the receiver contains at least one number in aRange.
-(BOOL)isEqualToIndexSet:(CPIndexSet)anIndexSet
          Compares the receiver with the provided index set.
-(int)lastIndex
          Returns the last index in the set.
-(id)mutableCopy
          Creates a deep copy of the index set.
-(void)removeAllIndexes
          Removes all indices from the set.
-(void)removeIndex:(unsigned int)anIndex
          Removes an index from the set.
-(void)removeIndexes:(CPIndexSet)anIndexSet
          Removes the indices from the receiving set.
-(void)removeIndexesInRange:(CPRange)aRange
          Removes the indices in the range from the set.
-(void)shiftIndexesStartingAtIndex:(unsigned)anIndex by:(int)aDelta
          Shifts the values of indices left or right by a specified amount.

Methods inherited from class CPObject
initialize, alloc, class, instanceMethodForSelector, instancesRespondToSelector, isSubclassOfClass, load, new, setVersion, superclass, version, init, autorelease, awakeAfterUsingCoder, class, classForCoder, classForKeyedArchiver, className, copy, dealloc, description, doesNotRecognizeSelector, forwardInvocation, hash, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableCopy, performSelector, performSelector, performSelector, release, replacementObjectForArchiver, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, retain, self, superclass


Method Detail

indexSet

+(id)indexSet
Returns a new empty index set.

indexSetWithIndex

+(id)indexSetWithIndex:(int)anIndex
Returns a new index set with just one index.
Parameters:
anIndex

indexSetWithIndexesInRange

+(id)indexSetWithIndexesInRange:(CPRange)aRange
Returns a new index set with all the numbers in the specified range.
Parameters:
aRange - the range of numbers to add to the index set.

init

-(id)init
Initializes the receiver
Returns:
the initialized receiver

initWithCoder

-(id)initWithCoder:(CPCoder)aCoder
Initializes the index set from a coder.
Parameters:
aCoder - the coder from which to read the index set data
Returns:
the initialized index set

initWithIndex

-(id)initWithIndex:(int)anIndex
Initializes the index set with a single index.
Parameters:
anIndex
Returns:
the initialized index set

initWithIndexSet

-(id)initWithIndexSet:(CPIndexSet)anIndexSet
Initializes the index set with another index set.
Parameters:
anIndexSet - the index set from which to read the initial index set
Returns:
the initialized index set

initWithIndexesInRange

-(id)initWithIndexesInRange:(CPRange)aRange
Initializes the index set with numbers from the specified range.
Parameters:
aRange - the range of numbers to add to the index set
Returns:
the initialized index set

addIndex

-(void)addIndex:(unsigned)anIndex
Adds an index to the set.
Parameters:
anIndex - the index to add

addIndexes

-(void)addIndexes:(CPIndexSet)anIndexSet
Adds indices to the set
Parameters:
anIndexSet - a set of indices to add to the receiver

addIndexesInRange

-(void)addIndexesInRange:(CPRange)aRange
Adds the range of indices to the set
Parameters:
aRange - the range of numbers to add as indices to the set

containsIndex

-(BOOL)containsIndex:(unsigned)anIndex
Returns YES if the index set contains the specified index.
Parameters:
anIndex - the index to check for in the set
Returns:
YES if anIndex is in the receiver index set

containsIndexes

-(BOOL)containsIndexes:(CPIndexSet)anIndexSet
Returns YES if the receving index set contains all the indices in the argument.
Parameters:
anIndexSet - the set of indices to check for in the receiving index set

containsIndexesInRange

-(BOOL)containsIndexesInRange:(CPRange)aRange
Returns YES if the index set contains all the numbers in the specified range.
Parameters:
aRange - the range of numbers to check for in the index set

copy

-(id)copy
Creates a deep copy of the index set. The returned copy is mutable. The reason for the two copy methods is for source compatability with GNUStep code.
Returns:
the index set copy

count

-(int)count
The number of indices in the set

description

-(CPString)description
Returns a human readable string describing the receiver

encodeWithCoder

-(void)encodeWithCoder:(CPCoder)aCoder
Writes out the index set to the specified coder.
Parameters:
aCoder - the coder to which the index set will be written

firstIndex

-(int)firstIndex
Return the first index in the set

getIndexes

-(unsigned)getIndexes:(CPArray)anArray maxCount:(unsigned)aMaxCount inIndexRange:(CPRange)aRangePointer
Fills up the specified array with numbers from the index set within the specified range. The method stops filling up the array until the aMaxCount number have been added or the range maximum is reached.
Parameters:
anArray - the array to fill up
aMaxCount - the maximum number of numbers to adds
aRangePointer - the range of indices to add
Returns:
the number of elements added to the array

indexGreaterThanIndex

-(unsigned)indexGreaterThanIndex:(unsigned)anIndex
Returns the first index value in the receiver which is greater than anIndex.
Parameters:
anIndex
Returns:
the closest index or CPNotFound if no match was found

indexGreaterThanOrEqualToIndex

-(unsigned int)indexGreaterThanOrEqualToIndex:(unsigned)anIndex
Returns the first index value in the receiver which is greater than or equal to anIndex.
Parameters:
anIndex
Returns:
the matching index or CPNotFound if no match was found

indexLessThanIndex

-(unsigned)indexLessThanIndex:(unsigned)anIndex
Returns the first index value in the receiver which is less than anIndex.
Parameters:
anIndex
Returns:
the closest index or CPNotFound if no match was found

indexLessThanOrEqualToIndex

-(unsigned int)indexLessThanOrEqualToIndex:(unsigned)anIndex
Returns the first index value in the receiver which is less than or equal to anIndex.
Parameters:
anIndex
Returns:
the matching index or CPNotFound if no match was found

intersectsIndexesInRange

-(BOOL)intersectsIndexesInRange:(CPRange)aRange
Checks if the receiver contains at least one number in aRange.
Parameters:
aRange - the range of numbers to check.
Returns:
YES if the receiving index set contains at least one number in the provided range

isEqualToIndexSet

-(BOOL)isEqualToIndexSet:(CPIndexSet)anIndexSet
Compares the receiver with the provided index set.
Parameters:
anIndexSet - the index set to compare to
Returns:
YES if the receiver and the index set are functionally equivalent

lastIndex

-(int)lastIndex
Returns the last index in the set

mutableCopy

-(id)mutableCopy
Creates a deep copy of the index set. The returned copy is mutable. The reason for the two copy methods is for source compatability with GNUStep code.
Returns:
the index set copy

removeAllIndexes

-(void)removeAllIndexes
Removes all indices from the set

removeIndex

-(void)removeIndex:(unsigned int)anIndex
Removes an index from the set
Parameters:
anIndex - the index to remove

removeIndexes

-(void)removeIndexes:(CPIndexSet)anIndexSet
Removes the indices from the receiving set.
Parameters:
anIndexSet - the set of indices to remove from the receiver

removeIndexesInRange

-(void)removeIndexesInRange:(CPRange)aRange
Removes the indices in the range from the set.
Parameters:
aRange - the range of indices to remove

shiftIndexesStartingAtIndex

-(void)shiftIndexesStartingAtIndex:(unsigned)anIndex by:(int)aDelta
Shifts the values of indices left or right by a specified amount.
Parameters:
anIndex - the index to start the shifting operation from (inclusive)
aDelta - the amount and direction to shift. A positive value shifts to the right. A negative value shifts to the left.

Created on Sat Sep 13 14:15:43 PDT 2008