Overview
Comment: | Add -[OFMutableArray initWithCapacity:]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e0c9168dfc81b15b0f7b7cb473d61c33 |
User & Date: | js on 2013-02-18 12:27:09 |
Other Links: | manifest | tags |
Context
2013-02-18
| ||
21:53 | Rename -[OFStream pendingBytes]. check-in: efe7be259d user: js tags: trunk | |
12:27 | Add -[OFMutableArray initWithCapacity:]. check-in: e0c9168dfc user: js tags: trunk | |
11:31 | A few small fixes for OS X/PPC. check-in: adaf5a3e6e user: js tags: trunk | |
Changes
Modified src/OFArray_adjacent.m from [a68b59eaa5] to [1c69665b63].
︙ | ︙ | |||
90 91 92 93 94 95 96 | } - initWithArray: (OFArray*)array { id *objects; size_t i, count; | | > > > | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | } - initWithArray: (OFArray*)array { id *objects; size_t i, count; self = [super init]; if (array == nil) return self; @try { objects = [array objects]; count = [array count]; _array = [[OFDataArray alloc] initWithItemSize: sizeof(id) capacity: count]; } @catch (id e) { [self release]; @throw e; } @try { for (i = 0; i < count; i++) |
︙ | ︙ |
Modified src/OFAutoreleasePool.m from [d0fc457afc] to [933769a877].
︙ | ︙ | |||
15 16 17 18 19 20 21 | */ #include "config.h" #include <stdlib.h> #import "OFAutoreleasePool.h" | < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | */ #include "config.h" #include <stdlib.h> #import "OFAutoreleasePool.h" #import "macros.h" #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) # import "threading.h" # import "OFInitializationFailedException.h" #endif |
︙ | ︙ |
Modified src/OFDictionary.h from [8191ea81be] to [e10f379adb].
︙ | ︙ | |||
114 115 116 117 118 119 120 | /*! * @brief Initializes an already allocated OFDictionary with the specified key * and object. * * @param key The key * @param object The object | | | | | | | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | /*! * @brief Initializes an already allocated OFDictionary with the specified key * and object. * * @param key The key * @param object The object * @return An initialized OFDictionary */ - initWithObject: (id)object forKey: (id)key; /*! * @brief Initializes an already allocated OFDictionary with the specified keys * and objects. * * @param keys An array of keys * @param objects An array of objects * @return An initialized OFDictionary */ - initWithObjects: (OFArray*)objects forKeys: (OFArray*)keys; /*! * @brief Initializes an already allocated OFDictionary with the specified keys * and objects. * * @param keys An array of keys * @param objects An array of objects * @param count The number of objects in the arrays * @return An initialized OFDictionary */ - initWithObjects: (id const*)objects forKeys: (id const*)keys count: (size_t)count; /*! * @brief Initializes an already allocated OFDictionary with the specified keys * and objects. * * @param firstKey The first key * @return An initialized OFDictionary */ - initWithKeysAndObjects: (id)firstKey, ... OF_SENTINEL; /*! * @brief Initializes an already allocated OFDictionary with the specified key * and va_list. * * @param firstKey The first key * @param arguments A va_list of the other arguments * @return An initialized OFDictionary */ - initWithKey: (id)firstKey arguments: (va_list)arguments; /*! * @brief Returns the object for the given key or nil if the key was not found. * |
︙ | ︙ |
Modified src/OFMutableArray.h from [81a3bf4a11] to [fa7a4d0116].
︙ | ︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #endif /*! * @brief An abstract class for storing, adding and removing objects in an * array. */ @interface OFMutableArray: OFArray /*! * @brief Adds an object to the end of the array. * * @param object An object to add */ - (void)addObject: (id)object; | > > > > > > > > > > > > > > > > > > | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #endif /*! * @brief An abstract class for storing, adding and removing objects in an * array. */ @interface OFMutableArray: OFArray /*! * @brief Creates a new OFMutableArray with enough memory to hold the specified * number of objects. * * @param capacity The initial capacity for the OFMutableArray * @return A new autoreleased OFMutableArray */ + (instancetype)arrayWithCapacity: (size_t)capacity; /*! * @brief Initializes an already allocated OFMutableArray with enough memory to * hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableArray * @return An initialized OFMutableArray */ - initWithCapacity: (size_t)capacity; /*! * @brief Adds an object to the end of the array. * * @param object An object to add */ - (void)addObject: (id)object; |
︙ | ︙ |
Modified src/OFMutableArray.m from [3a62a4c2fe] to [0ae8da9046].
︙ | ︙ | |||
82 83 84 85 86 87 88 89 90 91 92 93 94 95 | } @implementation OFMutableArray_placeholder - init { return (id)[[OFMutableArray_adjacent alloc] init]; } - initWithObject: (id)object { return (id)[[OFMutableArray_adjacent alloc] initWithObject: object]; } - initWithObjects: (id)firstObject, ... | > > > > > | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | } @implementation OFMutableArray_placeholder - init { return (id)[[OFMutableArray_adjacent alloc] init]; } - initWithCapacity: (size_t)capacity { return (id)[[OFMutableArray_adjacent alloc] initWithCapacity: capacity]; } - initWithObject: (id)object { return (id)[[OFMutableArray_adjacent alloc] initWithObject: object]; } - initWithObjects: (id)firstObject, ... |
︙ | ︙ | |||
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | + alloc { if (self == [OFMutableArray class]) return (id)&placeholder; return [super alloc]; } - init { if (object_getClass(self) == [OFMutableArray class]) { @try { [self doesNotRecognizeSelector: _cmd]; abort(); } @catch (id e) { [self release]; @throw e; } } return [super init]; } - copy { return [[OFArray alloc] initWithArray: self]; } - (void)addObject: (id)object | > > > > > > > > > > > > > > > > > | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | + alloc { if (self == [OFMutableArray class]) return (id)&placeholder; return [super alloc]; } + (instancetype)arrayWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } - init { if (object_getClass(self) == [OFMutableArray class]) { @try { [self doesNotRecognizeSelector: _cmd]; abort(); } @catch (id e) { [self release]; @throw e; } } return [super init]; } - initWithCapacity: (size_t)capacity { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } - copy { return [[OFArray alloc] initWithArray: self]; } - (void)addObject: (id)object |
︙ | ︙ |
Modified src/OFMutableArray_adjacent.m from [65e0f02167] to [95d0045e21].
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | @implementation OFMutableArray_adjacent + (void)initialize { if (self == [OFMutableArray_adjacent class]) [self inheritMethodsFromClass: [OFArray_adjacent class]]; } - (void)addObject: (id)object { if (object == nil) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; | > > > > > > > > > > > > > > > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | @implementation OFMutableArray_adjacent + (void)initialize { if (self == [OFMutableArray_adjacent class]) [self inheritMethodsFromClass: [OFArray_adjacent class]]; } - initWithCapacity: (size_t)capacity { self = [super init]; @try { _array = [[OFDataArray alloc] initWithItemSize: sizeof(id) capacity: capacity]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)addObject: (id)object { if (object == nil) @throw [OFInvalidArgumentException exceptionWithClass: [self class]]; |
︙ | ︙ |
Modified src/OFMutableDictionary.h from [2e2922b971] to [463267262c].
︙ | ︙ | |||
34 35 36 37 38 39 40 | + (instancetype)dictionaryWithCapacity: (size_t)capacity; /*! * @brief Initializes an already allocated OFMutableDictionary with enough * memory to hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableDictionary | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | + (instancetype)dictionaryWithCapacity: (size_t)capacity; /*! * @brief Initializes an already allocated OFMutableDictionary with enough * memory to hold the specified number of objects. * * @param capacity The initial capacity for the OFMutableDictionary * @return An initialized OFMutableDictionary */ - initWithCapacity: (size_t)capacity; /*! * @brief Sets an object for a key. * * A key can be any object that conforms to the OFCopying protocol. |
︙ | ︙ |
Modified src/OFMutableDictionary.m from [0f0750039f] to [00eb95393f].
︙ | ︙ | |||
133 134 135 136 137 138 139 | { if (self == [OFMutableDictionary class]) return (id)&placeholder; return [super alloc]; } | | | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | { if (self == [OFMutableDictionary class]) return (id)&placeholder; return [super alloc]; } + (instancetype)dictionaryWithCapacity: (size_t)capacity { return [[[self alloc] initWithCapacity: capacity] autorelease]; } - init { if (object_getClass(self) == [OFMutableDictionary class]) { |
︙ | ︙ |