CPArray Class Reference
[Foundation]

A mutable array backed by a JavaScript Array.A mutable array class backed by a JavaScript Array. There is also a CPMutableArray class, but it is just a child class of this class with an empty implementation. All mutable functionality is implemented directly in CPArray. More...

List of all members.

Public Member Functions

(void) - addObject: [implementation]
(void) - addObjectsFromArray: [implementation]
(CPArray- arrayByAddingObject: [implementation]
(CPArray- arrayByAddingObjectsFromArray: [implementation]
(CPString- componentsJoinedByString: [implementation]
(BOOL) - containsObject: [implementation]
(id) - copy [implementation]
(int) - count [implementation]
(CPString- description [implementation]
(void) - encodeWithCoder: [implementation]
(void) - exchangeObjectAtIndex:withObjectAtIndex: [implementation]
(id) - firstObjectCommonWithArray: [implementation]
(int) - indexOfObject: [implementation]
(int) - indexOfObject:inRange: [implementation]
(unsigned) - indexOfObject:sortedByDescriptors: [implementation]
(unsigned) - indexOfObject:sortedByFunction: [implementation]
(unsigned) - indexOfObject:sortedByFunction:context: [implementation]
(unsigned) - indexOfObject:sortedBySelector: [implementation]
(int) - indexOfObjectIdenticalTo: [implementation]
(int) - indexOfObjectIdenticalTo:inRange: [implementation]
(id) - init [implementation]
(id) - initWithArray: [implementation]
(id) - initWithArray:copyItems: [implementation]
(id) - initWithCapacity: [implementation]
(id) - initWithCoder: [implementation]
(id) - initWithObjects: [implementation]
(id) - initWithObjects:count: [implementation]
(void) - insertObject:atIndex: [implementation]
(void) - insertObjects:atIndexes: [implementation]
(BOOL) - isEqual: [implementation]
(BOOL) - isEqualToArray: [implementation]
(id) - lastObject [implementation]
(void) - makeObjectsPerformSelector: [implementation]
(void) - makeObjectsPerformSelector:withObject: [implementation]
(void) - makeObjectsPerformSelector:withObjects: [implementation]
(id) - objectAtIndex: [implementation]
(CPEnumerator- objectEnumerator [implementation]
(CPArray- objectsAtIndexes: [implementation]
(CPArray- pathsMatchingExtensions: [implementation]
(void) - removeAllObjects [implementation]
(void) - removeLastObject [implementation]
(void) - removeObject: [implementation]
(void) - removeObject:inRange: [implementation]
(void) - removeObjectAtIndex: [implementation]
(void) - removeObjectIdenticalTo: [implementation]
(void) - removeObjectIdenticalTo:inRange: [implementation]
(void) - removeObjectsAtIndexes: [implementation]
(void) - removeObjectsInArray: [implementation]
(void) - removeObjectsInRange: [implementation]
(void) - replaceObjectAtIndex:withObject: [implementation]
(void) - replaceObjectsAtIndexes:withObjects: [implementation]
(void) - replaceObjectsInRange:withObjectsFromArray: [implementation]
(void) - replaceObjectsInRange:withObjectsFromArray:range: [implementation]
(CPEnumerator- reverseObjectEnumerator [implementation]
(void) - setArray: [implementation]
(void) - setValue:forKey: [implementation]
(void) - setValue:forKeyPath: [implementation]
(CPArray- sortedArrayUsingDescriptors: [implementation]
(CPArray- sortedArrayUsingFunction: [implementation]
(CPArray- sortedArrayUsingFunction:context: [implementation]
(CPArray- sortedArrayUsingSelector: [implementation]
(CPArray- sortUsingDescriptors: [implementation]
(void) - sortUsingFunction:context: [implementation]
(void) - sortUsingSelector: [implementation]
(CPArray- subarrayWithRange: [implementation]
(id) - valueForKey: [implementation]
(id) - valueForKeyPath: [implementation]

Static Public Member Functions

(id) + array [implementation]
(id) + arrayWithArray: [implementation]
(CPArray+ arrayWithCapacity: [implementation]
(id) + arrayWithObject: [implementation]
(id) + arrayWithObjects: [implementation]
(id) + arrayWithObjects:count: [implementation]

Detailed Description

A mutable array backed by a JavaScript Array.

A mutable array class backed by a JavaScript Array. There is also a CPMutableArray class, but it is just a child class of this class with an empty implementation. All mutable functionality is implemented directly in CPArray.

Definition at line 302 of file CPArray+KVO.j.


Member Function Documentation

- (void) addObject: (id)  anObject   [implementation]

Adds anObject to the end of the array.

Parameters:
anObject the object to add to the array

Definition at line 926 of file CPArray.j.

- (void) addObjectsFromArray: (CPArray anArray   [implementation]

Adds the objects in anArray to the receiver array.

Parameters:
anArray the array of objects to add to the end of the receiver

Definition at line 935 of file CPArray.j.

+ (id) array   [implementation]

Returns a new initialized CPArray.

Definition at line 114 of file CPArray.j.

- (CPArray) arrayByAddingObject: (id)  anObject   [implementation]

Returns a copy of this array plus anObject inside the copy.

Parameters:
anObject the object to be added to the array copy
Exceptions:
CPInvalidArgumentException if anObject is nil
Returns:
a new array that should be n+1 in size compared to the receiver.

Definition at line 685 of file CPArray.j.

- (CPArray) arrayByAddingObjectsFromArray: (CPArray anArray   [implementation]

Returns a new array which is the concatenation of self and otherArray (in this precise order).

Parameters:
anArray the array that will be concatenated to the receiver's copy

Definition at line 702 of file CPArray.j.

+ (id) arrayWithArray: (CPArray anArray   [implementation]

Creates a new array containing the objects in anArray.

Parameters:
anArray Objects in this array will be added to the new array
Returns:
a new CPArray of the provided objects

Definition at line 124 of file CPArray.j.

+ (CPArray) arrayWithCapacity: (unsigned)  aCapacity   [implementation]

Creates an array able to store at least aCapacity items. Because CPArray is backed by JavaScript arrays, this method ends up simply returning a regular array.

Definition at line 907 of file CPArray.j.

+ (id) arrayWithObject: (id)  anObject   [implementation]

Creates a new array with anObject in it.

Parameters:
anObject the object to be added to the array
Returns:
a new CPArray containing a single object

Definition at line 134 of file CPArray.j.

+ (id) arrayWithObjects: (id)  anObject
,   ... 
[implementation]

Creates a new CPArray containing all the objects passed as arguments to the method.

Parameters:
anObject the objects that will be added to the new array
Returns:
a new CPArray containing the argument objects

Definition at line 144 of file CPArray.j.

+ (id) arrayWithObjects: (id)  objects
count: (unsigned)  aCount 
[implementation]

Creates a CPArray from a JavaScript array of objects.

Parameters:
objects the JavaScript Array
aCount the number of objects in the JS Array
Returns:
a new CPArray containing the specified objects

Definition at line 162 of file CPArray.j.

- (CPString) componentsJoinedByString: (CPString aString   [implementation]

Returns a string formed by concatenating the objects in the receiver, with the specified separator string inserted between each part. If the element is a Objective-J object, then the -description of that object will be used, otherwise the default JavaScript representation will be used.

Parameters:
aString the separator that will separate each object string
Returns:
the string representation of the array

Definition at line 796 of file CPArray.j.

- (BOOL) containsObject: (id)  anObject   [implementation]

Returns YES if the array contains anObject. Otherwise, it returns NO.

Parameters:
anObject the method checks if this object is already in the array

Definition at line 266 of file CPArray.j.

- (id) copy   [implementation]

Makes a copy of the receiver.

Returns:
a new CPArray copy

Definition at line 892 of file CPArray.j.

- (int) count   [implementation]

Returns the number of elements in the array

Definition at line 274 of file CPArray.j.

- (CPString) description   [implementation]

Returns a human readable description of this array and it's elements.

Definition at line 808 of file CPArray.j.

- (void) encodeWithCoder: (CPCoder aCoder   [implementation]

Definition at line 1216 of file CPArray.j.

- (void) exchangeObjectAtIndex: (unsigned)  anIndex
withObjectAtIndex: (unsigned)  otherIndex 
[implementation]

Swaps the elements at the two specified indices.

Parameters:
anIndex the first index to swap from
otherIndex the second index to swap from

Definition at line 1165 of file CPArray.j.

- (id) firstObjectCommonWithArray: (CPArray anArray   [implementation]

Returns the first object found in the receiver (starting at index 0) which is present in the otherArray as determined by using the -containsObject: method.

Returns:
the first object found, or nil if no common object was found.

Definition at line 625 of file CPArray.j.

- (int) indexOfObject: (id)  anObject   [implementation]

Returns the index of anObject in this array. If the object is nil or not in the array, returns CPNotFound. It first attempts to find a match using -isEqual:, then ==.

Parameters:
anObject the object to search for

Definition at line 286 of file CPArray.j.

- (int) indexOfObject: (id)  anObject
inRange: (CPRange)  aRange 
[implementation]

Returns the index of anObject in the array within aRange. It first attempts to find a match using -isEqual:, then ==.

Parameters:
anObject the object to search for
aRange the range to search within
Returns:
the index of the object, or CPNotFound if it was not found.

Definition at line 322 of file CPArray.j.

- (unsigned) indexOfObject: (id)  anObject
sortedByDescriptors: (CPArray descriptors 
[implementation]

Returns the index of anObject in the array, which must be sorted in the same order as calling sortUsingDescriptors: with the descriptors passed to this method would result in.

Parameters:
anObject the object to search for
descriptors the array of descriptors to use to compare each item in the array that we search. the same descriptors should have been used to sort the array (or to maintain its sorted order).
Returns:
the index of the object, or CPNotFound if it was not found.

Definition at line 490 of file CPArray.j.

- (unsigned) indexOfObject: (id)  anObject
sortedByFunction: (Function)  aFunction 
[implementation]

Returns the index of anObject in the array, which must be sorted in the same order as calling sortUsingFunction: with the selector passed to this method would result in. The function will be called like so:

    aFunction(anObject, currentObjectInArrayForComparison)
    
Parameters:
anObject the object to search for
aFunction the comparison function to call on each item in the array that we search. the same selector should have been used to sort the array (or to maintain its sorted order).
Returns:
the index of the object, or CPNotFound if it was not found.

Definition at line 437 of file CPArray.j.

- (unsigned) indexOfObject: (id)  anObject
sortedByFunction: (Function)  aFunction
context: (id)  aContext 
[implementation]

Returns the index of anObject in the array, which must be sorted in the same order as calling sortUsingFunction: with the selector passed to this method would result in. The function will be called like so:

    aFunction(anObject, currentObjectInArrayForComparison, context)
    
Parameters:
anObject the object to search for
aFunction the comparison function to call on each item in the array that we search. the same function should have been used to sort the array (or to maintain its sorted order).
aContext a context object that will be passed to the sort function
Returns:
the index of the object, or CPNotFound if it was not found.

Definition at line 455 of file CPArray.j.

- (unsigned) indexOfObject: (id)  anObject
sortedBySelector: (SEL)  aSelector 
[implementation]

Returns the index of anObject in the array, which must be sorted in the same order as calling sortUsingSelector: with the selector passed to this method would result in.

Parameters:
anObject the object to search for
aSelector the comparison selector to call on each item in the list, the same selector should have been used to sort the array (or to maintain its sorted order).
Returns:
the index of the object, or CPNotFound if it was not found.

Definition at line 420 of file CPArray.j.

- (int) indexOfObjectIdenticalTo: (id)  anObject   [implementation]

Returns the index of anObject in the array. The test for equality is done using only ==.

Parameters:
anObject the object to search for
Returns:
the index of the object in the array. CPNotFound if the object is not in the array.

Definition at line 351 of file CPArray.j.

- (int) indexOfObjectIdenticalTo: (id)  anObject
inRange: (CPRange)  aRange 
[implementation]

Returns the index of anObject in the array within aRange. The test for equality is done using only ==.

Parameters:
anObject the object to search for
aRange the range to search within
Returns:
the index of the object, or CPNotFound if it was not found.

Definition at line 383 of file CPArray.j.

- (id) init   [implementation]

Initializes the CPArray.

Returns:
the initialized array

Definition at line 171 of file CPArray.j.

- (id) initWithArray: (CPArray anArray   [implementation]

Creates a new CPArray from anArray.

Parameters:
anArray objects in this array will be added to the new array
Returns:
a new CPArray containing the objects of anArray

Definition at line 182 of file CPArray.j.

- (id) initWithArray: (CPArray anArray
copyItems: (BOOL)  copyItems 
[implementation]

Initializes a the array with the contents of anArray and optionally performs a deep copy of the objects based on copyItems.

Parameters:
anArray the array to copy the data from
copyItems if YES, each object will be copied by having a -copy message sent to it, and the returned object will be added to the receiver. Otherwise, no copying will be performed.
Returns:
the initialized array of objects

Definition at line 200 of file CPArray.j.

- (id) initWithCapacity: (unsigned)  aCapacity   [implementation]

Initializes an array able to store at least aCapacity items. Because CPArray is backed by JavaScript arrays, this method ends up simply returning a regular array.

Definition at line 916 of file CPArray.j.

- (id) initWithCoder: (CPCoder aCoder   [implementation]

Definition at line 1211 of file CPArray.j.

- (id) initWithObjects: (Array)  anArray
,   ... 
[implementation]

initializes an array with the contents of anArray

Definition at line 228 of file CPArray.j.

- (id) initWithObjects: (id)  objects
count: (unsigned)  aCount 
[implementation]

Initializes the array with a JavaScript array of objects.

Parameters:
objects the array of objects to add to the receiver
aCount the number of objects in objects
Returns:
the initialized CPArray

Definition at line 246 of file CPArray.j.

- (void) insertObject: (id)  anObject
atIndex: (int)  anIndex 
[implementation]

Inserts an object into the receiver at the specified location.

Parameters:
anObject the object to insert into the array
anIndex the location to insert anObject at

Definition at line 945 of file CPArray.j.

- (void) insertObjects: (CPArray objects
atIndexes: (CPIndexSet indexes 
[implementation]

Inserts the objects in the provided array into the receiver at the indexes specified.

Parameters:
objects the objects to add to this array
anIndexSet the indices for the objects

Definition at line 955 of file CPArray.j.

- (BOOL) isEqual: (id)  anObject   [implementation]

Definition at line 667 of file CPArray.j.

- (BOOL) isEqualToArray: (id)  anArray   [implementation]

Returns true if anArray contains exactly the same objects as the reciever.

Definition at line 643 of file CPArray.j.

- (id) lastObject   [implementation]

Returns the last object in the array. If the array is empty, returns nil/

Definition at line 509 of file CPArray.j.

- (void) makeObjectsPerformSelector: (SEL)  aSelector   [implementation]

Sends each element in the array a message.

Parameters:
aSelector the selector of the message to send
Exceptions:
CPInvalidArgumentException if aSelector is nil

Definition at line 572 of file CPArray.j.

- (void) makeObjectsPerformSelector: (SEL)  aSelector
withObject: (id)  anObject 
[implementation]

Sends each element in the array a message with an argument.

Parameters:
aSelector the selector of the message to send
anObject the first argument of the message
Exceptions:
CPInvalidArgumentException if aSelector is nil

Definition at line 590 of file CPArray.j.

- (void) makeObjectsPerformSelector: (SEL)  aSelector
withObjects: (CPArray objects 
[implementation]

Definition at line 602 of file CPArray.j.

- (id) objectAtIndex: (int)  anIndex   [implementation]

Returns the object at index anIndex.

Exceptions:
CPRangeException if anIndex is out of bounds

Definition at line 522 of file CPArray.j.

- (CPEnumerator) objectEnumerator   [implementation]

Returns an enumerator describing the array sequentially from the first to the last element. You should not modify the array during enumeration.

Definition at line 551 of file CPArray.j.

- (CPArray) objectsAtIndexes: (CPIndexSet indexes   [implementation]

Returns the objects at indexes in a new CPArray.

Parameters:
indexes the set of indices
Exceptions:
CPRangeException if any of the indices is greater than or equal to the length of the array

Definition at line 535 of file CPArray.j.

- (CPArray) pathsMatchingExtensions: (CPArray filterTypes   [implementation]

Returns a new array subset formed by selecting the elements that have filename extensions from filterTypes. Only elements that are of type CPString are candidates for inclusion in the returned array.

Parameters:
filterTypes an array of CPString objects that contain file extensions (without the '.')
Returns:
a new array with matching paths

Definition at line 841 of file CPArray.j.

- (void) removeAllObjects   [implementation]

Removes all objects from this array.

Definition at line 1046 of file CPArray.j.

- (void) removeLastObject   [implementation]

Removes the last object from the array.

Definition at line 1054 of file CPArray.j.

- (void) removeObject: (id)  anObject   [implementation]

Removes all entries of anObject from the array.

Parameters:
anObject the object whose entries are to be removed

Definition at line 1063 of file CPArray.j.

- (void) removeObject: (id)  anObject
inRange: (CPRange)  aRange 
[implementation]

Removes all entries of anObject from the array, in the range specified by aRange.

Parameters:
anObject the object to remove
aRange the range to search in the receiver for the object

Definition at line 1073 of file CPArray.j.

- (void) removeObjectAtIndex: (int)  anIndex   [implementation]

Removes the object at anIndex.

Parameters:
anIndex the location of the element to be removed

Definition at line 1088 of file CPArray.j.

- (void) removeObjectIdenticalTo: (id)  anObject   [implementation]

Remove the first instance of anObject from the array. The search for the object is done using ==.

Parameters:
anObject the object to remove

Definition at line 1113 of file CPArray.j.

- (void) removeObjectIdenticalTo: (id)  anObject
inRange: (CPRange)  aRange 
[implementation]

Remove the first instance of anObject from the array, within the range specified by aRange. The search for the object is done using ==.

Parameters:
anObject the object to remove
aRange the range in the array to search for the object

Definition at line 1125 of file CPArray.j.

- (void) removeObjectsAtIndexes: (CPIndexSet anIndexSet   [implementation]

Removes the objects at the indices specified by CPIndexSet.

Parameters:
anIndexSet the indices of the elements to be removed from the array

Definition at line 1097 of file CPArray.j.

- (void) removeObjectsInArray: (CPArray anArray   [implementation]

Remove the objects in anArray from the receiver array.

Parameters:
anArray the array of objects to remove from the receiver

Definition at line 1141 of file CPArray.j.

- (void) removeObjectsInRange: (CPRange)  aRange   [implementation]

Removes all the objects in the specified range from the receiver.

Parameters:
aRange the range of objects to remove

Definition at line 1154 of file CPArray.j.

- (void) replaceObjectAtIndex: (int)  anIndex
withObject: (id)  anObject 
[implementation]

Replaces the element at anIndex with anObject. The current element at position anIndex will be removed from the array.

Parameters:
anIndex the position in the array to place anObject

Definition at line 980 of file CPArray.j.

- (void) replaceObjectsAtIndexes: (CPIndexSet anIndexSet
withObjects: (CPArray objects 
[implementation]

Replace the elements at the indices specified by anIndexSet with the objects in objects.

Parameters:
anIndexSet the set of indices to array positions that will be replaced
objects the array of objects to place in the specified indices

Definition at line 991 of file CPArray.j.

- (void) replaceObjectsInRange: (CPRange)  aRange
withObjectsFromArray: (CPArray anArray 
[implementation]

Replaces some of the receiver's objects with the objects from anArray. Specifically, the elements of the receiver in the range specified by aRange.

Parameters:
aRange the range of elements to be replaced in the receiver
anArray the array to retrieve objects for placement into the receiver

Definition at line 1026 of file CPArray.j.

- (void) replaceObjectsInRange: (CPRange)  aRange
withObjectsFromArray: (CPArray anArray
range: (CPRange)  otherRange 
[implementation]

Replaces some of the receiver's objects with objects from anArray. Specifically, the elements of the receiver in the range specified by aRange, with the elements of anArray in the range specified by otherRange.

Parameters:
aRange the range of elements to be replaced in the receiver
anArray the array to retrieve objects for placement into the receiver
otherRange the range of objects in anArray to pull from for placement into the receiver

Definition at line 1011 of file CPArray.j.

- (CPEnumerator) reverseObjectEnumerator   [implementation]

Returns an enumerator describing the array sequentially from the last to the first element. You should not modify the array during enumeration.

Definition at line 561 of file CPArray.j.

- (void) setArray: (CPArray anArray   [implementation]

Sets the contents of the receiver to be identical to the contents of anArray.

Parameters:
anArray the array of objects used to replace the receiver's objects

Definition at line 1035 of file CPArray.j.

- (void) setValue: (id)  aValue
forKey: (CPString aKey 
[implementation]

Sets the key-value for each element in the array.

Parameters:
aValue the value for the coding
aKey the key for the coding

Definition at line 378 of file CPArray+KVO.j.

- (void) setValue: (id)  aValue
forKeyPath: (CPString aKeyPath 
[implementation]

Definition at line 387 of file CPArray+KVO.j.

- (CPArray) sortedArrayUsingDescriptors: (CPArray descriptors   [implementation]

Definition at line 739 of file CPArray.j.

- (CPArray) sortedArrayUsingFunction: (Function)  aFunction   [implementation]

Return a copy of the receiver sorted using the function passed into the first parameter.

Definition at line 751 of file CPArray.j.

- (CPArray) sortedArrayUsingFunction: (Function)  aFunction
context: (id)  aContext 
[implementation]

Returns an array in which the objects are ordered according to a sort with aFunction. This invokes -sortUsingFunction:context.

Parameters:
aFunction a JavaScript 'Function' type that compares objects
aContext context information
Returns:
a new sorted array

Definition at line 764 of file CPArray.j.

- (CPArray) sortedArrayUsingSelector: (SEL)  aSelector   [implementation]

Returns a new array in which the objects are ordered according to a sort with aSelector.

Parameters:
aSelector the selector that will perform object comparisons

Definition at line 777 of file CPArray.j.

- (CPArray) sortUsingDescriptors: (CPArray descriptors   [implementation]

Definition at line 1172 of file CPArray.j.

- (void) sortUsingFunction: (Function)  aFunction
context: (id)  aContext 
[implementation]

Sorts the receiver array using a JavaScript function as a comparator, and a specified context.

Parameters:
aFunction a JavaScript function that will be called to compare objects
aContext an object that will be passed to aFunction with comparison

Definition at line 1193 of file CPArray.j.

- (void) sortUsingSelector: (SEL)  aSelector   [implementation]

Sorts the receiver array using an Objective-J method as a comparator.

Parameters:
aSelector the selector for the method to call for comparison

Definition at line 1202 of file CPArray.j.

- (CPArray) subarrayWithRange: (CPRange)  aRange   [implementation]

Returns a subarray of the receiver containing the objects found in the specified range aRange.

Parameters:
aRange the range of objects to be copied into the subarray
Exceptions:
CPRangeException if the specified range exceeds the bounds of the array

Definition at line 727 of file CPArray.j.

- (CPArray) valueForKey: (CPString aKey   [implementation]

Returns the value for aKey from each element in the array.

Parameters:
aKey the key to return the value for
Returns:
an array of containing a value for each element in the array

Definition at line 304 of file CPArray+KVO.j.

- (id) valueForKeyPath: (CPString aKeyPath   [implementation]

Definition at line 337 of file CPArray+KVO.j.


The documentation for this class was generated from the following files:

Generated on Fri Apr 9 11:04:20 2010 for Cappuccino API by  doxygen 1.6.1