picofuse-objc

Instance Methods | Class Methods | List of all members
NXArray Class Reference

An ordered list of objects, which can be changed. More...

#import <Foundation/Foundation.h>

Inheritance diagram for NXArray:
Inheritance graph
[legend]
Collaboration diagram for NXArray:
Collaboration graph
[legend]

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...
 

Detailed Description

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.

Definition at line 26 of file NXArray.h.

Method Documentation

◆ appendObject:()

- (BOOL) appendObject: (id)  object

Adds an object to the end.

Returns
YES if it was added, or NO if it's nil or there isn't enough memory.

◆ arrayWithCapacity:()

+ (id) arrayWithCapacity: (size_t)  capacity

Returns an empty array with room for a number of objects.

Returns
The array, or nil if there isn't enough memory.

◆ arrayWithObjects:()

+ (id) arrayWithObjects: (id)  firstObject
,   ... 

Returns an array of objects, which ends with nil.

Returns
The array, or nil if there isn't enough memory.

◆ componentsJoinedByString:()

- (NXString *) componentsJoinedByString: (NXString *)  separator

Returns the objects joined into a string, with a separator between them.

Strings are joined as they are, and other objects by their description.

Parameters
separatorThe separator, or nil for none.
Returns
The string, which is empty if there are no objects, or nil if there isn't enough memory.

◆ copy()

- (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.

◆ insertObject:atIndex:()

- (BOOL) insertObject: (id)  object
atIndex: (size_t)  index 

Inserts an object at an index, moving those from there along.

Parameters
objectThe object, which is retained.
indexFrom zero to the number of objects, which adds it to the end.
Returns
YES if it was inserted, or NO if it's nil, the index is beyond the end, or there isn't enough memory.

◆ removeLastObject()

- (BOOL) removeLastObject

Removes the last object.

Returns
YES if it was removed, or NO if the array is empty.

◆ removeObject:()

- (size_t) removeObject: (id)  object

Removes every object equal to one, by isEqual:.

Returns
The number which were removed.

◆ removeObjectAtIndex:()

- (BOOL) removeObjectAtIndex: (size_t)  index

Removes the object at an index, moving those after it back.

Returns
YES if it was removed, or NO if there isn't an object there.

◆ replaceObjectAtIndex:withObject:()

- (BOOL) replaceObjectAtIndex: (size_t)  index
withObject: (id)  object 

Replaces the object at an index.

Returns
YES if it was replaced, or NO if it's nil or there isn't an object there.

◆ sortUsingSelector:()

- (BOOL) sortUsingSelector: (SEL)  comparator

Sorts the objects, by sending each a comparator, such as @selector(compare:), with the other as its argument, which returns an NXComparisonResult.

Returns
YES, or NO if the comparator is NULL or there isn't enough memory, when the order isn't changed.

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.

◆ subarrayFromIndex:count:()

- (NXArray *) subarrayFromIndex: (size_t)  index
count: (size_t)  count 

Returns a new array with some of the objects, in the same order.

Parameters
indexThe index of the first.
countThe number of them.
Returns
The array, or nil if they'd run past the end or there isn't enough memory.

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