ObjFW
|
An abstract class for storing objects in an array. More...
#import <OFArray.h>
Public Member Functions | |
(id) | - initWithObject: |
Initializes an OFArray with the specified object. | |
(id) | - initWithObjects: |
Initializes an OFArray with the specified objects. | |
(id) | - initWithObject:arguments: |
Initializes an OFArray with the specified object and a va_list. | |
(id) | - initWithArray: |
Initializes an OFArray with the objects from the specified array. | |
(id) | - initWithCArray: |
Initializes an OFArray with the objects from the specified C array. | |
(id) | - initWithCArray:length: |
Initializes an OFArray with the objects from the specified C array of the specified length. | |
(id) | - objectAtIndex: |
Returns a specified object of the array. | |
(void) | - getObjects:inRange: |
Copies the objects at the specified range to the specified buffer. | |
(id *) | - cArray |
Returns the objects of the array as a C array. | |
(size_t) | - indexOfObject: |
Returns the index of the first object that is equivalent to the specified object or OF_INVALID_INDEX if it was not found. | |
(size_t) | - indexOfObjectIdenticalTo: |
Returns the index of the first object that has the same address as the specified object or OF_INVALID_INDEX if it was not found. | |
(BOOL) | - containsObjectIdenticalTo: |
Checks whether the array contains an object with the specified address. | |
(id) | - firstObject |
Returns the first object of the array or nil. | |
(id) | - lastObject |
Returns the last object of the array or nil. | |
(OFArray *) | - objectsInRange: |
Returns the objects in the specified range as a new OFArray. | |
(OFString *) | - componentsJoinedByString: |
Creates a string by joining all objects of the array. | |
(OFString *) | - componentsJoinedByString:usingSelector: |
Creates a string by calling the selector on all objects of the array and joining the strings returned by calling the selector. | |
(void) | - makeObjectsPerformSelector: |
Performs the specified selector on all objects in the array. | |
(void) | - makeObjectsPerformSelector:withObject: |
Performs the specified selector on all objects in the array with the specified object. | |
(OFArray *) | - sortedArray |
Returns a sorted copy of the array. | |
(OFArray *) | - reversedArray |
Returns a copy of the array with the order reversed. | |
(void) | - enumerateObjectsUsingBlock: |
Executes a block for each object. | |
(OFArray *) | - mappedArrayUsingBlock: |
Creates a new array, mapping each object using the specified block. | |
(OFArray *) | - filteredArrayUsingBlock: |
Creates a new array, only containing the objects for which the block returns YES. | |
(id) | - foldUsingBlock: |
Folds the array to a single object using the specified block. | |
Static Public Member Functions | |
(id) | + array |
Creates a new OFArray. | |
(id) | + arrayWithObject: |
Creates a new OFArray with the specified object. | |
(id) | + arrayWithObjects: |
Creates a new OFArray with the specified objects, terminated by nil. | |
(id) | + arrayWithArray: |
Creates a new OFArray with the objects from the specified array. | |
(id) | + arrayWithCArray: |
Creates a new OFArray with the objects from the specified C array. | |
(id) | + arrayWithCArray:length: |
Creates a new OFArray with the objects from the specified C array of the specified length. |
An abstract class for storing objects in an array.
+ (id) arrayWithArray: | (OFArray*) | array |
+ (id) arrayWithCArray: | (id*) | objects |
+ (id) arrayWithCArray: | (id*) | objects | |
length: | (size_t) | length | |
+ (id) arrayWithObject: | (id) | object |
+ (id) arrayWithObjects: | (id) | firstObject | |
, | ... | ||
- (id *) cArray |
Returns the objects of the array as a C array.
Creates a string by joining all objects of the array.
separator | The string with which the objects should be joined |
Creates a string by calling the selector on all objects of the array and joining the strings returned by calling the selector.
separator | The string with which the objects should be joined |
selector | The selector to perform on the objects |
- (BOOL) containsObjectIdenticalTo: | (id) | object |
Checks whether the array contains an object with the specified address.
object | The object which is checked for being in the array |
- (void) enumerateObjectsUsingBlock: | (of_array_enumeration_block_t) | block |
Executes a block for each object.
block | The block to execute for each object |
- (OFArray *) filteredArrayUsingBlock: | (of_array_filter_block_t) | block |
Creates a new array, only containing the objects for which the block returns YES.
block | A block which determines if the object should be in the new array |
- (id) firstObject |
Returns the first object of the array or nil.
The returned object is not retained and autoreleased for performance reasons!
- (id) foldUsingBlock: | (of_array_fold_block_t) | block |
Folds the array to a single object using the specified block.
If the array is empty, it will return nil.
If there is only one object in the array, that object will be returned and the block will not be invoked.
If there are at least two objects, the block is invoked for each object except the first, where left is always to what the array has already been folded and right what should be added to left.
block | A block which folds two objects into one, which is called for all objects except the first |
- (void) getObjects: | (id*) | buffer | |
inRange: | (of_range_t) | range | |
Copies the objects at the specified range to the specified buffer.
buffer | The buffer to copy the objects to |
range | The range to copy |
- (size_t) indexOfObject: | (id) | object |
Returns the index of the first object that is equivalent to the specified object or OF_INVALID_INDEX if it was not found.
object | The object whose index is returned |
- (size_t) indexOfObjectIdenticalTo: | (id) | object |
Returns the index of the first object that has the same address as the specified object or OF_INVALID_INDEX if it was not found.
object | The object whose index is returned |
- (id) initWithArray: | (OFArray*) | array |
- (id) initWithCArray: | (id*) | objects |
- (id) initWithCArray: | (id*) | objects | |
length: | (size_t) | length | |
- (id) initWithObject: | (id) | object |
- (id) initWithObject: | (id) | firstObject | |
arguments: | (va_list) | arguments | |
- (id) initWithObjects: | (id) | firstObject | |
, | ... | ||
- (id) lastObject |
Returns the last object of the array or nil.
The returned object is not retained and autoreleased for performance reasons!
- (void) makeObjectsPerformSelector: | (SEL) | selector |
Performs the specified selector on all objects in the array.
selector | The selector to perform on all objects in the array |
- (void) makeObjectsPerformSelector: | (SEL) | selector | |
withObject: | (id) | object | |
Performs the specified selector on all objects in the array with the specified object.
selector | The selector to perform on all objects in the array |
object | The object to perform the selector with on all objects in the array |
- (OFArray *) mappedArrayUsingBlock: | (of_array_map_block_t) | block |
Creates a new array, mapping each object using the specified block.
block | A block which maps an object for each object |
- (id) objectAtIndex: | (size_t) | index |
Returns a specified object of the array.
The returned object is not retained and autoreleased for performance reasons!
index | The number of the object to return |
- (OFArray *) objectsInRange: | (of_range_t) | range |
- (OFArray *) reversedArray |
Returns a copy of the array with the order reversed.
- (OFArray *) sortedArray |
Returns a sorted copy of the array.