ObjFW
|
00001 /* 00002 * Copyright (c) 2008, 2009, 2010, 2011 00003 * Jonathan Schleifer <js@webkeks.org> 00004 * 00005 * All rights reserved. 00006 * 00007 * This file is part of ObjFW. It may be distributed under the terms of the 00008 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in 00009 * the packaging of this file. 00010 * 00011 * Alternatively, it may be distributed under the terms of the GNU General 00012 * Public License, either version 2 or 3, which can be found in the file 00013 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this 00014 * file. 00015 */ 00016 00017 #include <stdarg.h> 00018 00019 #import "OFObject.h" 00020 #import "OFCollection.h" 00021 #import "OFEnumerator.h" 00022 00023 @class OFDataArray; 00024 @class OFString; 00025 00026 #ifdef OF_HAVE_BLOCKS 00027 typedef void (^of_array_enumeration_block_t)(id obj, size_t idx, BOOL *stop); 00028 typedef BOOL (^of_array_filter_block_t)(id odj, size_t idx); 00029 typedef id (^of_array_map_block_t)(id obj, size_t idx); 00030 #endif 00031 00035 @interface OFArray: OFObject <OFCopying, OFMutableCopying, OFCollection, 00036 OFFastEnumeration> 00037 { 00038 OFDataArray *array; 00039 } 00040 00044 + array; 00045 00052 + arrayWithObject: (id)obj; 00053 00060 + arrayWithObjects: (id)first, ...; 00061 00068 + arrayWithCArray: (id*)objs; 00069 00078 + arrayWithCArray: (id*)objs 00079 length: (size_t)len; 00080 00087 - initWithObject: (id)obj; 00088 00095 - initWithObjects: (id)first, ...; 00096 00104 - initWithObject: (id)first 00105 argList: (va_list)args; 00106 00113 - initWithCArray: (id*)objs; 00114 00123 - initWithCArray: (id*)objs 00124 length: (size_t)len; 00125 00129 - (id*)cArray; 00130 00140 - (id)objectAtIndex: (size_t)index; 00141 00150 - (size_t)indexOfObject: (id)obj; 00151 00160 - (size_t)indexOfObjectIdenticalTo: (id)obj; 00161 00170 - (id)firstObject; 00171 00180 - (id)lastObject; 00181 00191 - (OFArray*)objectsFromIndex: (size_t)start 00192 toIndex: (size_t)end; 00193 00199 - (OFArray*)objectsInRange: (of_range_t)range; 00200 00207 - (OFString*)componentsJoinedByString: (OFString*)separator; 00208 00214 - (void)makeObjectsPerformSelector: (SEL)selector; 00215 00224 - (void)makeObjectsPerformSelector: (SEL)selector 00225 withObject: (id)obj; 00226 00227 #ifdef OF_HAVE_BLOCKS 00228 00233 - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block; 00234 00241 - (OFArray*)mappedArrayUsingBlock: (of_array_map_block_t)block; 00242 00251 - (OFArray*)filteredArrayUsingBlock: (of_array_filter_block_t)block; 00252 #endif 00253 @end 00254 00255 @interface OFArrayEnumerator: OFEnumerator 00256 { 00257 OFArray *array; 00258 OFDataArray *dataArray; 00259 size_t count; 00260 unsigned long mutations; 00261 unsigned long *mutationsPtr; 00262 size_t pos; 00263 } 00264 00265 - initWithArray: (OFArray*)data 00266 dataArray: (OFDataArray*)dataArray 00267 mutationsPointer: (unsigned long*)mutationsPtr; 00268 @end 00269 00270 #import "OFMutableArray.h"