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...
#import <CPArray.h>
List of all members.
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 2 of file CPArray.h.
Method Documentation
- (CPArray) arrayByAddingObject: |
|
(id) |
anObject |
|
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 628 of file CPArray.j.
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 643 of file CPArray.j.
+ (id) arrayWithArray: |
|
(CPArray) |
anArray |
|
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 85 of file CPArray.j.
+ (id) arrayWithObject: |
|
(id) |
anObject |
|
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 95 of file CPArray.j.
+ (id) arrayWithObjects: |
|
(id) |
anObject |
, |
|
|
... |
|
|
| |
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 105 of file CPArray.j.
+ (id) arrayWithObjects: |
|
(id) |
objects |
count: |
|
(unsigned) |
aCount |
|
|
| |
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 119 of file CPArray.j.
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 753 of file CPArray.j.
- (BOOL) containsObject: |
|
(id) |
anObject |
|
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 187 of file CPArray.j.
- (BOOL) containsObjectIdenticalTo: |
|
(id) |
anObject |
|
Makes a copy of the receiver.
- Returns:
- a new CPArray copy
Definition at line 815 of file CPArray.j.
Returns the number of elements in the array
Definition at line 200 of file CPArray.j.
Returns a human readable description of this array and it's elements.
Definition at line 763 of file CPArray.j.
- (void) encodeWithCoder: |
|
(CPCoder) |
aCoder |
|
- (void) enumerateObjectsUsingBlock: |
|
(Function) |
aFunction |
|
Returns the first object in the array. If the array is empty, returns nil
Definition at line 208 of file CPArray.j.
- (id) firstObjectCommonWithArray: |
|
(CPArray) |
anArray |
|
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 552 of file CPArray.j.
- (CPUInteger) indexOfObject: |
|
(id) |
anObject |
|
Returns the index of anObject
in this array. If the object is 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 283 of file CPArray.j.
- (CPUInteger) indexOfObject: |
|
(id) |
anObject |
inRange: |
|
(CPRange) |
aRange |
|
|
| |
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 296 of file CPArray.j.
- (CPUInteger) indexOfObject: |
|
(id) |
anObject |
inSortedRange: |
|
(CPRange) |
aRange |
options: |
|
(CPBinarySearchingOptions) |
options |
usingComparator: |
|
(Function) |
aComparator |
|
|
| |
- (CPUInteger) indexOfObjectIdenticalTo: |
|
(id) |
anObject |
|
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 319 of file CPArray.j.
- (CPUInteger) indexOfObjectIdenticalTo: |
|
(id) |
anObject |
inRange: |
|
(CPRange) |
aRange |
|
|
| |
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 332 of file CPArray.j.
- (unsigned) indexOfObjectPassingTest: |
|
(Function) |
aPredicate |
|
Returns the index of the first object in the receiver that passes a test in a given Javascript function.
- Parameters:
-
predicate | The function to apply to elements of the array. The function receives two arguments: object The element in the array. index The index of the element in the array. The predicate function should either return a Boolean value that indicates whether the object passed the test, or nil to stop the search, which will return CPNotFound to the sender. |
- Returns:
- The index of the first matching object, or
CPNotFound
if there is no matching object.
Definition at line 353 of file CPArray.j.
- (unsigned) indexOfObjectPassingTest: |
|
(Function) |
aPredicate |
context: |
|
(id) |
aContext |
|
|
| |
Returns the index of the first object in the receiver that passes a test in a given Javascript function.
- Parameters:
-
predicate | The function to apply to elements of the array. The function receives two arguments: object The element in the array. index The index of the element in the array. context The object passed to the receiver in the aContext parameter. The predicate function should either return a Boolean value that indicates whether the object passed the test, or nil to stop the search, which will return CPNotFound to the sender. |
context | An object that contains context information you want passed to the predicate function. |
- Returns:
- The index of the first matching object, or
CPNotFound
if there is no matching object.
Definition at line 369 of file CPArray.j.
- (unsigned) indexOfObjectWithOptions: |
|
(CPEnumerationOptions) |
options |
passingTest: |
|
(Function) |
aPredicate |
|
|
| |
Returns the index of the first object in the receiver that passes a test in a given Javascript function.
- Parameters:
-
options | Specifies the direction in which the array is searched. Pass CPEnumerationNormal to search forwards or CPEnumerationReverse to search in reverse. |
predicate | The function to apply to elements of the array. The function receives two arguments: object The element in the array. index The index of the element in the array. The predicate function should either return a Boolean value that indicates whether the object passed the test, or nil to stop the search, which will return CPNotFound to the sender. |
- Returns:
- The index of the first matching object, or
CPNotFound
if there is no matching object.
Definition at line 385 of file CPArray.j.
- (unsigned) indexOfObjectWithOptions: |
|
(CPEnumerationOptions) |
options |
passingTest: |
|
(Function) |
aPredicate |
context: |
|
(id) |
aContext |
|
|
| |
Returns the index of the first object in the receiver that passes a test in a given Javascript function.
- Parameters:
-
options | Specifies the direction in which the array is searched. Pass CPEnumerationNormal to search forwards or CPEnumerationReverse to search in reverse. |
predicate | The function to apply to elements of the array. The function receives two arguments: object The element in the array. index The index of the element in the array. context The object passed to the receiver in the aContext parameter. The predicate function should either return a Boolean value that indicates whether the object passed the test, or nil to stop the search, which will return CPNotFound to the sender. |
context | An object that contains context information you want passed to the predicate function. |
- Returns:
- The index of the first matching object, or
CPNotFound
if there is no matching object.
Definition at line 403 of file CPArray.j.
Initializes the CPArray.
- Returns:
- the initialized array
Definition at line 128 of file CPArray.j.
- (id) initWithArray: |
|
(CPArray) |
anArray |
|
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 139 of file CPArray.j.
- (id) initWithArray: |
|
(CPArray) |
anArray |
copyItems: |
|
(BOOL) |
shouldCopyItems |
|
|
| |
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 |
shouldCopyItems | 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 152 of file CPArray.j.
- (id) initWithCapacity: |
|
(unsigned) |
aCapacity |
|
- (id) initWithCoder: |
|
(CPCoder) |
aCoder |
|
- (id) initWithObjects: |
|
(id) |
anObject |
, |
|
|
... |
|
|
| |
initializes an array with the contents of anArray
Definition at line 160 of file CPArray.j.
- (id) initWithObjects: |
|
(id) |
objects |
count: |
|
(unsigned) |
aCount |
|
|
| |
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 171 of file CPArray.j.
- (BOOL) isEqual: |
|
(id) |
anObject |
|
- (BOOL) isEqualToArray: |
|
(id) |
anArray |
|
Returns true if anArray contains exactly the same objects as the receiver.
Definition at line 575 of file CPArray.j.
Returns the last object in the array. If the array is empty, returns nil
Definition at line 221 of file CPArray.j.
- (void) makeObjectsPerformSelector: |
|
(SEL) |
aSelector |
|
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 496 of file CPArray.j.
- (void) makeObjectsPerformSelector: |
|
(SEL) |
aSelector |
withObject: |
|
(id) |
anObject |
|
|
| |
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 507 of file CPArray.j.
- (void) makeObjectsPerformSelector: |
|
(SEL) |
aSelector |
withObjects: |
|
(CPArray) |
objects |
|
|
| |
- (id) objectAtIndex: |
|
(int) |
anIndex |
|
Returns the object at index anIndex
.
- Exceptions:
-
CPRangeException | if anIndex is out of bounds |
Definition at line 235 of file CPArray.j.
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 261 of file CPArray.j.
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 245 of file CPArray.j.
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 796 of file CPArray.j.
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 271 of file CPArray.j.
- (void) setValue: |
|
(id) |
aValue |
forKey: |
|
(CPString) |
aKey |
|
|
| |
- (void) setValue: |
|
(id) |
aValue |
forKeyPath: |
|
(CPString) |
aKeyPath |
|
|
| |
- (CPArray) sortedArrayUsingFunction: |
|
(Function) |
aFunction |
|
Return a copy of the receiver sorted using the function passed into the first parameter.
Definition at line 708 of file CPArray.j.
- (CPArray) sortedArrayUsingFunction: |
|
(Function) |
aFunction |
context: |
|
(id) |
aContext |
|
|
| |
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 721 of file CPArray.j.
- (CPArray) sortedArrayUsingSelector: |
|
(SEL) |
aSelector |
|
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 734 of file CPArray.j.
- (CPArray) subarrayWithRange: |
|
(CPRange) |
aRange |
|
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 674 of file CPArray.j.
- (id) valueForKeyPath: |
|
(CPString) |
aKeyPath |
|
The documentation for this class was generated from the following files: