ObjFW
src/OFArray.h
00001 /*
00002  * Copyright (c) 2008, 2009, 2010, 2011, 2012
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 #ifndef __STDC_LIMIT_MACROS
00018 # define __STDC_LIMIT_MACROS
00019 #endif
00020 #ifndef __STDC_CONSTANT_MACROS
00021 # define __STDC_CONSTANT_MACROS
00022 #endif
00023 
00024 #include <stdarg.h>
00025 
00026 #import "OFObject.h"
00027 #import "OFCollection.h"
00028 #import "OFEnumerator.h"
00029 #import "OFSerialization.h"
00030 #import "OFJSONEncoding.h"
00031 
00032 @class OFString;
00033 
00034 #ifdef OF_HAVE_BLOCKS
00035 typedef void (^of_array_enumeration_block_t)(id object, size_t index,
00036     BOOL *stop);
00037 typedef BOOL (^of_array_filter_block_t)(id odject, size_t index);
00038 typedef id (^of_array_map_block_t)(id object, size_t index);
00039 typedef id (^of_array_fold_block_t)(id left, id right);
00040 #endif
00041 
00045 @interface OFArray: OFObject <OFCopying, OFMutableCopying, OFCollection,
00046     OFSerialization, OFJSON>
00047 #ifdef OF_HAVE_PROPERTIES
00048 @property (readonly) size_t count;
00049 #endif
00050 
00056 + array;
00057 
00064 + arrayWithObject: (id)object;
00065 
00072 + arrayWithObjects: (id)firstObject, ...;
00073 
00080 + arrayWithArray: (OFArray*)array;
00081 
00088 + arrayWithCArray: (id*)objects;
00089 
00098 + arrayWithCArray: (id*)objects
00099            length: (size_t)length;
00100 
00107 - initWithObject: (id)object;
00108 
00115 - initWithObjects: (id)firstObject, ...;
00116 
00124 - initWithObject: (id)firstObject
00125        arguments: (va_list)arguments;
00126 
00133 - initWithArray: (OFArray*)array;
00134 
00141 - initWithCArray: (id*)objects;
00142 
00151 - initWithCArray: (id*)objects
00152           length: (size_t)length;
00153 
00163 - (id)objectAtIndex: (size_t)index;
00164 
00171 - (void)getObjects: (id*)buffer
00172            inRange: (of_range_t)range;
00173 
00179 - (id*)cArray;
00180 
00189 - (size_t)indexOfObject: (id)object;
00190 
00199 - (size_t)indexOfObjectIdenticalTo: (id)object;
00200 
00209 - (BOOL)containsObjectIdenticalTo: (id)object;
00210 
00219 - (id)firstObject;
00220 
00229 - (id)lastObject;
00230 
00237 - (OFArray*)objectsInRange: (of_range_t)range;
00238 
00245 - (OFString*)componentsJoinedByString: (OFString*)separator;
00246 
00255 - (OFString*)componentsJoinedByString: (OFString*)separator
00256                         usingSelector: (SEL)selector;
00257 
00263 - (void)makeObjectsPerformSelector: (SEL)selector;
00264 
00273 - (void)makeObjectsPerformSelector: (SEL)selector
00274                         withObject: (id)object;
00275 
00281 - (OFArray*)sortedArray;
00282 
00288 - (OFArray*)reversedArray;
00289 
00290 #ifdef OF_HAVE_BLOCKS
00291 
00296 - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block;
00297 
00304 - (OFArray*)mappedArrayUsingBlock: (of_array_map_block_t)block;
00305 
00314 - (OFArray*)filteredArrayUsingBlock: (of_array_filter_block_t)block;
00315 
00332 - (id)foldUsingBlock: (of_array_fold_block_t)block;
00333 #endif
00334 @end
00335 
00336 @interface OFArrayEnumerator: OFEnumerator
00337 {
00338         OFArray       *array;
00339         size_t        count;
00340         unsigned long mutations;
00341         unsigned long *mutationsPtr;
00342         size_t        position;
00343 }
00344 
00345 - initWithArray: (OFArray*)data
00346    mutationsPtr: (unsigned long*)mutationsPtr;
00347 @end
00348 
00349 #import "OFMutableArray.h"
 All Classes Functions Variables Properties