An ordered list of objects, which can be changed. More...
#import <Foundation/Foundation.h>


Instance Methods | |
| (id) | - initWithCapacity: |
| Initializes an empty array with room for a number of objects. | |
| (id) | - initWithObjects: |
| Initializes an array of objects, which ends with nil. | |
| (size_t) | - count |
| Returns the number of objects. | |
| (size_t) | - capacity |
| Returns the number of objects there's room for, before more memory is needed. | |
| (id) | - objectAtIndex: |
| Returns the object at an index, or nil if there isn't one. | |
| (id) | - firstObject |
| Returns the first object, or nil if the array is empty. | |
| (id) | - lastObject |
| Returns the last object, or nil if the array is empty. | |
| (size_t) | - indexOfObject: |
| Returns the index of the first object equal to one, by isEqual:, or NXNotFound. | |
| (BOOL) | - containsObject: |
| Returns YES if an object equal to one, by isEqual:, is in the array. | |
| (BOOL) | - appendObject: |
| Adds an object to the end. More... | |
| (BOOL) | - insertObject:atIndex: |
| Inserts an object at an index, moving those from there along. More... | |
| (BOOL) | - replaceObjectAtIndex:withObject: |
| Replaces the object at an index. More... | |
| (BOOL) | - removeObjectAtIndex: |
| Removes the object at an index, moving those after it back. More... | |
| (size_t) | - removeObject: |
| Removes every object equal to one, by isEqual:. More... | |
| (BOOL) | - removeLastObject |
| Removes the last object. More... | |
| (void) | - removeAllObjects |
| Removes every object, but keeps the room for them. | |
| (BOOL) | - isEqual: |
| Returns YES if another object is an array of equal objects, by isEqual:, in the same order. | |
| (uintptr_t) | - hash |
| Returns a hash of the objects, in order, which is the same for equal arrays. | |
| (id) | - copy |
| Returns a new array of the same objects, which are retained by it too, or nil if there isn't enough memory. More... | |
| (NXString *) | - description |
| Returns the descriptions of the objects, such as "[1, 2, three]". | |
| (NXArray *) | - subarrayFromIndex:count: |
| Returns a new array with some of the objects, in the same order. More... | |
| (NXString *) | - componentsJoinedByString: |
| Returns the objects joined into a string, with a separator between them. More... | |
| (BOOL) | - sortUsingSelector: |
| Sorts the objects, by sending each a comparator, such as @selector(compare:), with the other as its argument, which returns an NXComparisonResult. More... | |
Instance Methods inherited from NXObject | |
| (void) | - dealloc |
| Frees the instance. More... | |
| (NXZone *) | - zone |
| Returns the zone in which the instance was allocated. More... | |
| (id) | - retain |
| Increases the retain count of the receiver. More... | |
| (void) | - release |
| Decreases the retain count of the receiver. More... | |
| (id) | - autorelease |
| Releases the receiver later, when the current autorelease pool of the thread is drained. More... | |
Instance Methods inherited from Object | |
| (id) | - init |
| Initialize the instance, after allocation. More... | |
| (Class) | - class |
| Returns the class of the instance. More... | |
| (Class) | - superclass |
| Returns the superclass of the instance. More... | |
| (BOOL) | - isKindOfClass: |
| Returns a Boolean value that indicates whether the receiver is an instance of a given class. More... | |
| (BOOL) | - conformsTo: |
| Checks if the receiver's class conforms to a protocol. More... | |
Instance Methods inherited from <ObjectProtocol> | |
| (BOOL) | - respondsToSelector: |
| Checks if the receiver responds to a selector. More... | |
Instance Methods inherited from <NXFastEnumeration> | |
| (unsigned long) | - countByEnumeratingWithState:objects:count: |
| Returns the next batch of objects for a for...in loop. More... | |
Class Methods | |
| (id) | + array |
| Returns an empty array. | |
| (id) | + arrayWithCapacity: |
| Returns an empty array with room for a number of objects. More... | |
| (id) | + arrayWithObjects: |
| Returns an array of objects, which ends with nil. More... | |
Class Methods inherited from NXObject | |
| (id) | + alloc |
| Allocates a new instance in the default zone, or if there isn't one, with sys_calloc(). More... | |
| (id) | + allocWithZone: |
| Allocates a new instance in a specific zone. More... | |
| (id) | + new |
| Allocates and initializes a new instance, as [[cls alloc] init] does. More... | |
Class Methods inherited from Object | |
| (void) | + initialize |
| Performs one-time initialization for the class. More... | |
| (Class) | + class |
| Returns the class object. More... | |
| (Class) | + superclass |
| Returns the superclass of the class. More... | |
| (const char *) | + name |
| Returns the name of the class. More... | |
| (BOOL) | + conformsTo: |
| Checks if the class conforms to a protocol. More... | |
Additional Inherited Members | |
Protected Attributes inherited from Object | |
| Class | isa |
| A pointer to the object's class structure. More... | |
An ordered list of objects, which can be changed.
The objects are retained while they're in the array, and released when they're removed or the array is deallocated. They're kept one after another in memory from the array's zone, which is twice as big when more room is needed. An array can't hold nil, so NXNull is used instead.
A for...in loop goes through the objects in order. Adding or removing objects in the loop panics, unless it then stops with break, but replacing one doesn't.
Any number of threads can read an array at once, but while one changes it, no other thread can use it, and it doesn't lock itself. See Threads and mutable objects.
Adds an object to the end.
| + (id) arrayWithCapacity: | (size_t) | capacity |
Returns an empty array with room for a number of objects.
Returns an array of objects, which ends with nil.
Returns the objects joined into a string, with a separator between them.
Strings are joined as they are, and other objects by their description.
| separator | The separator, or nil for none. |
| - (id) copy |
Returns a new array of the same objects, which are retained by it too, or nil if there isn't enough memory.
The caller owns it and has to release it.
Implements NXObject.
Inserts an object at an index, moving those from there along.
| object | The object, which is retained. |
| index | From zero to the number of objects, which adds it to the end. |
| - (BOOL) removeLastObject |
Removes the last object.
| - (size_t) removeObject: | (id) | object |
Removes every object equal to one, by isEqual:.
| - (BOOL) removeObjectAtIndex: | (size_t) | index |
Removes the object at an index, moving those after it back.
Replaces the object at an index.
Sorts the objects, by sending each a comparator, such as @selector(compare:), with the other as its argument, which returns an NXComparisonResult.
Objects which are the same keep their order. It needs room for half the objects in the array's zone while it sorts. Sorting in a for...in loop over the array panics.
| - (NXArray *) subarrayFromIndex: | (size_t) | index | |
| count: | (size_t) | count | |
Returns a new array with some of the objects, in the same order.
| index | The index of the first. |
| count | The number of them. |