diff options
author | Starla Insigna <starla4444@gmail.com> | 2011-07-30 11:19:14 -0400 |
---|---|---|
committer | Starla Insigna <starla4444@gmail.com> | 2011-07-30 11:19:14 -0400 |
commit | 9cd57b731ab1c666d4a1cb725538fdc137763d12 (patch) | |
tree | 5bac45ae5157a1cb10c6e45500cbf72789917980 /libs/cocos2d/Support/CCArray.h | |
download | cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.tar.gz cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.tar.bz2 cartcollect-9cd57b731ab1c666d4a1cb725538fdc137763d12.zip |
Initial commit (version 0.2.1)
Diffstat (limited to 'libs/cocos2d/Support/CCArray.h')
-rwxr-xr-x | libs/cocos2d/Support/CCArray.h | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/libs/cocos2d/Support/CCArray.h b/libs/cocos2d/Support/CCArray.h new file mode 100755 index 0000000..0c7b2b8 --- /dev/null +++ b/libs/cocos2d/Support/CCArray.h | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org | ||
3 | * | ||
4 | * Copyright (c) 2010 ForzeField Studios S.L. http://forzefield.com | ||
5 | * | ||
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
7 | * of this software and associated documentation files (the "Software"), to deal | ||
8 | * in the Software without restriction, including without limitation the rights | ||
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
10 | * copies of the Software, and to permit persons to whom the Software is | ||
11 | * furnished to do so, subject to the following conditions: | ||
12 | * | ||
13 | * The above copyright notice and this permission notice shall be included in | ||
14 | * all copies or substantial portions of the Software. | ||
15 | * | ||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
22 | * THE SOFTWARE. | ||
23 | */ | ||
24 | |||
25 | |||
26 | #import "ccCArray.h" | ||
27 | |||
28 | |||
29 | /** A faster alternative of NSArray. | ||
30 | CCArray uses internally a c-array. | ||
31 | @since v0.99.4 | ||
32 | */ | ||
33 | |||
34 | |||
35 | /** @def CCARRAY_FOREACH | ||
36 | A convience macro to iterate over a CCArray using. It is faster than the "fast enumeration" interface. | ||
37 | @since v0.99.4 | ||
38 | */ | ||
39 | |||
40 | #define CCARRAY_FOREACH(__array__, __object__) \ | ||
41 | if (__array__ && __array__->data->num > 0) \ | ||
42 | for(id *__arr__ = __array__->data->arr, *end = __array__->data->arr + __array__->data->num-1; \ | ||
43 | __arr__ <= end && ((__object__ = *__arr__) != nil || true); \ | ||
44 | __arr__++) | ||
45 | |||
46 | @interface CCArray : NSObject <NSFastEnumeration, NSCoding, NSCopying> | ||
47 | { | ||
48 | @public ccArray *data; | ||
49 | } | ||
50 | |||
51 | + (id) array; | ||
52 | + (id) arrayWithCapacity:(NSUInteger)capacity; | ||
53 | + (id) arrayWithArray:(CCArray*)otherArray; | ||
54 | + (id) arrayWithNSArray:(NSArray*)otherArray; | ||
55 | |||
56 | |||
57 | - (id) initWithCapacity:(NSUInteger)capacity; | ||
58 | - (id) initWithArray:(CCArray*)otherArray; | ||
59 | - (id) initWithNSArray:(NSArray*)otherArray; | ||
60 | |||
61 | |||
62 | // Querying an Array | ||
63 | |||
64 | - (NSUInteger) count; | ||
65 | - (NSUInteger) capacity; | ||
66 | - (NSUInteger) indexOfObject:(id)object; | ||
67 | - (id) objectAtIndex:(NSUInteger)index; | ||
68 | - (BOOL) containsObject:(id)object; | ||
69 | - (id) randomObject; | ||
70 | - (id) lastObject; | ||
71 | - (NSArray*) getNSArray; | ||
72 | |||
73 | |||
74 | // Adding Objects | ||
75 | |||
76 | - (void) addObject:(id)object; | ||
77 | - (void) addObjectsFromArray:(CCArray*)otherArray; | ||
78 | - (void) addObjectsFromNSArray:(NSArray*)otherArray; | ||
79 | - (void) insertObject:(id)object atIndex:(NSUInteger)index; | ||
80 | |||
81 | |||
82 | // Removing Objects | ||
83 | |||
84 | - (void) removeLastObject; | ||
85 | - (void) removeObject:(id)object; | ||
86 | - (void) removeObjectAtIndex:(NSUInteger)index; | ||
87 | - (void) removeObjectsInArray:(CCArray*)otherArray; | ||
88 | - (void) removeAllObjects; | ||
89 | - (void) fastRemoveObject:(id)object; | ||
90 | - (void) fastRemoveObjectAtIndex:(NSUInteger)index; | ||
91 | |||
92 | |||
93 | // Rearranging Content | ||
94 | |||
95 | - (void) exchangeObject:(id)object1 withObject:(id)object2; | ||
96 | - (void) exchangeObjectAtIndex:(NSUInteger)index1 withObjectAtIndex:(NSUInteger)index2; | ||
97 | - (void) reverseObjects; | ||
98 | - (void) reduceMemoryFootprint; | ||
99 | |||
100 | // Sending Messages to Elements | ||
101 | |||
102 | - (void) makeObjectsPerformSelector:(SEL)aSelector; | ||
103 | - (void) makeObjectsPerformSelector:(SEL)aSelector withObject:(id)object; | ||
104 | |||
105 | |||
106 | @end | ||