|
cocos2d for iPhone 1.0.0
2D engine for iOS and OS X
|
00001 /* 00002 * cocos2d for iPhone: http://www.cocos2d-iphone.org 00003 * 00004 * Copyright (c) 2010 ForzeField Studios S.L. http://forzefield.com 00005 * 00006 * Permission is hereby granted, free of charge, to any person obtaining a copy 00007 * of this software and associated documentation files (the "Software"), to deal 00008 * in the Software without restriction, including without limitation the rights 00009 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00010 * copies of the Software, and to permit persons to whom the Software is 00011 * furnished to do so, subject to the following conditions: 00012 * 00013 * The above copyright notice and this permission notice shall be included in 00014 * all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00019 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00022 * THE SOFTWARE. 00023 */ 00024 00025 00026 #import "ccCArray.h" 00027 00028 00040 #define CCARRAY_FOREACH(__array__, __object__) \ 00041 if (__array__ && __array__->data->num > 0) \ 00042 for(id *__arr__ = __array__->data->arr, *end = __array__->data->arr + __array__->data->num-1; \ 00043 __arr__ <= end && ((__object__ = *__arr__) != nil || true); \ 00044 __arr__++) 00045 00046 @interface CCArray : NSObject <NSFastEnumeration, NSCoding, NSCopying> 00047 { 00048 @public ccArray *data; 00049 } 00050 00051 + (id) array; 00052 + (id) arrayWithCapacity:(NSUInteger)capacity; 00053 + (id) arrayWithArray:(CCArray*)otherArray; 00054 + (id) arrayWithNSArray:(NSArray*)otherArray; 00055 00056 00057 - (id) initWithCapacity:(NSUInteger)capacity; 00058 - (id) initWithArray:(CCArray*)otherArray; 00059 - (id) initWithNSArray:(NSArray*)otherArray; 00060 00061 00062 // Querying an Array 00063 00064 - (NSUInteger) count; 00065 - (NSUInteger) capacity; 00066 - (NSUInteger) indexOfObject:(id)object; 00067 - (id) objectAtIndex:(NSUInteger)index; 00068 - (BOOL) containsObject:(id)object; 00069 - (id) randomObject; 00070 - (id) lastObject; 00071 - (NSArray*) getNSArray; 00072 00073 00074 // Adding Objects 00075 00076 - (void) addObject:(id)object; 00077 - (void) addObjectsFromArray:(CCArray*)otherArray; 00078 - (void) addObjectsFromNSArray:(NSArray*)otherArray; 00079 - (void) insertObject:(id)object atIndex:(NSUInteger)index; 00080 00081 00082 // Removing Objects 00083 00084 - (void) removeLastObject; 00085 - (void) removeObject:(id)object; 00086 - (void) removeObjectAtIndex:(NSUInteger)index; 00087 - (void) removeObjectsInArray:(CCArray*)otherArray; 00088 - (void) removeAllObjects; 00089 - (void) fastRemoveObject:(id)object; 00090 - (void) fastRemoveObjectAtIndex:(NSUInteger)index; 00091 00092 00093 // Rearranging Content 00094 00095 - (void) exchangeObject:(id)object1 withObject:(id)object2; 00096 - (void) exchangeObjectAtIndex:(NSUInteger)index1 withObjectAtIndex:(NSUInteger)index2; 00097 - (void) reverseObjects; 00098 - (void) reduceMemoryFootprint; 00099 00100 // Sending Messages to Elements 00101 00102 - (void) makeObjectsPerformSelector:(SEL)aSelector; 00103 - (void) makeObjectsPerformSelector:(SEL)aSelector withObject:(id)object; 00104 00105 00106 @end