17 #ifndef __STDC_LIMIT_MACROS
18 # define __STDC_LIMIT_MACROS
20 #ifndef __STDC_CONSTANT_MACROS
21 # define __STDC_CONSTANT_MACROS
27 #import "OFCollection.h"
28 #import "OFEnumerator.h"
29 #import "OFSerialization.h"
30 #import "OFJSONRepresentation.h"
31 #import "OFMessagePackRepresentation.h"
33 OF_ASSUME_NONNULL_BEGIN
40 OF_ARRAY_SKIP_EMPTY = 1,
41 OF_ARRAY_SORT_DESCENDING = 2,
89 #ifdef OF_HAVE_GENERICS
90 @interface OFArray <ObjectType>:
93 # define ObjectType id
99 #ifdef OF_HAVE_PROPERTIES
100 @property (readonly)
size_t count;
108 + (instancetype)
array;
116 + (instancetype)arrayWithObject: (ObjectType)object;
124 + (instancetype)arrayWithObjects: (ObjectType)
firstObject, ... OF_SENTINEL;
132 + (instancetype)arrayWithArray: (
OFArray OF_GENERIC(ObjectType)*)
array;
143 arrayWithObjects: (ObjectType
const OF_NONNULL *OF_NONNULL)
objects
152 - initWithObject: (ObjectType)
object;
160 - initWithObjects: (ObjectType)
firstObject, ... OF_SENTINEL;
169 - initWithObject: (ObjectType)firstObject
170 arguments: (va_list)arguments;
178 - initWithArray: (
OFArray OF_GENERIC(ObjectType)*)
array;
188 - initWithObjects: (ObjectType
const OF_NONNULL *OF_NONNULL)
objects
200 - (ObjectType)objectAtIndex: (
size_t)index;
201 - (ObjectType)objectAtIndexedSubscript: (
size_t)index;
209 - (void)getObjects: (ObjectType __unsafe_unretained OF_NONNULL *OF_NONNULL)
218 - (ObjectType
const __unsafe_unretained OF_NONNULL *OF_NONNULL)
objects;
228 - (size_t)indexOfObject: (ObjectType)object;
238 - (size_t)indexOfObjectIdenticalTo: (ObjectType)object;
247 - (bool)containsObject: (nullable ObjectType)object;
257 - (bool)containsObjectIdenticalTo: (nullable ObjectType)object;
267 - (nullable ObjectType)firstObject;
307 options: (int)options;
318 usingSelector: (SEL)selector;
334 usingSelector: (SEL)selector
335 options: (
int)options;
342 - (void)makeObjectsPerformSelector: (
SEL)selector;
352 - (void)makeObjectsPerformSelector: (
SEL)selector
353 withObject: (nullable id)
object;
372 - (
OFArray OF_GENERIC(ObjectType)*)sortedArrayWithOptions: (
int)options;
387 - (
OFArray OF_GENERIC(ObjectType)*)arrayByAddingObject: (ObjectType)object;
395 - (
OFArray OF_GENERIC(ObjectType)*)arrayByAddingObjectsFromArray:
404 - (
OFArray OF_GENERIC(ObjectType)*)arrayByRemovingObject: (ObjectType)object;
414 #ifdef OF_HAVE_BLOCKS
438 - (
OFArray OF_GENERIC(ObjectType)*)filteredArrayUsingBlock:
460 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
468 unsigned long _mutations;
469 unsigned long *_mutationsPtr;
473 - initWithArray: (
OFArray*)data
474 mutationsPtr: (
unsigned long *OF_NULLABLE)mutationsPtr;
477 OF_ASSUME_NONNULL_END
481 #ifndef NSINTEGER_DEFINED
483 @compatibility_alias NSArray
OFArray;
A protocol for serializing objects.
Definition: OFSerialization.h:30
instancetype array()
Creates a new OFArray.
Definition: OFArray.m:133
An abstract class for storing objects in an array.
Definition: OFArray.h:95
nullable ObjectType firstObject()
Returns the first object of the array or nil.
Definition: OFArray.m:322
The root class for all other classes inside ObjFW.
Definition: OFObject.h:364
nullable ObjectType lastObject()
Returns the last object of the array or nil.
Definition: OFArray.m:330
id OF_NULLABLE(^ of_array_fold_block_t)(id OF_NULLABLE left, id right)
A block for folding an OFArray.
Definition: OFArray.h:81
ObjectType const __unsafe_unretained OF_NONNULL *OF_NONNULL objects()
Returns the objects of the array as a C array.
Definition: OFArray.m:243
A protocol implemented by classes that support encoding to a JSON representation. ...
Definition: OFJSONRepresentation.h:38
OFEnumerator OF_GENERIC(ObjectType objectEnumerator()
Returns an OFEnumerator to enumerate through all objects of the array.
Definition: OFArray.m:752
A class for handling strings.
Definition: OFString.h:91
size_t count()
Returns the number of objects in the collection.
void(^ of_array_enumeration_block_t)(id object, size_t index, bool *stop)
A block for enumerating an OFArray.
Definition: OFArray.h:53
OFArray OF_GENERIC(ObjectType sortedArray()
Returns a sorted copy of the array.
Definition: OFArray.m:694
A protocol with methods common for all collections.
Definition: OFCollection.h:26
bool(^ of_array_filter_block_t)(id object, size_t index)
A block for filtering an OFArray.
Definition: OFArray.h:63
A protocol implemented by classes that support encoding to a MessagePack representation.
Definition: OFMessagePackRepresentation.h:30
A range.
Definition: OFObject.h:65
A protocol for the creation of mutable copies.
Definition: OFObject.h:917
A protocol for the creation of copies.
Definition: OFObject.h:896
id OF_NONNULL(^ of_array_map_block_t)(id object, size_t index)
A block for mapping objects to objects in an OFArray.
Definition: OFArray.h:72
A class which provides methods to enumerate through collections.
Definition: OFEnumerator.h:52
OFArray OF_GENERIC(ObjectType reversedArray()
Returns a copy of the array with the order reversed.
Definition: OFArray.m:716