Differences From Artifact [e388818b36]:
- File
src/OFMutableArray_adjacent.m
— part of check-in
[95e8e1e486]
at
2012-06-10 16:03:01
on branch trunk
— Add a few array methods.
OFArray:
* +[arrayByAddingObject:]
* +[arrayByAddingObjectsFromArray:]OFMutableArray:
* -[addObjectsFromArray:]
* -[insertObjectsFromArray:atIndex:] (user: js, size: 6351) [annotate] [blame] [check-ins using] [more...]
To Artifact [6feaf02274]:
- File src/OFMutableArray_adjacent.m — part of check-in [8892ae9fcc] at 2012-07-12 01:28:46 on branch trunk — Don't access isa directly. (user: js, size: 6422) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
88 89 90 91 92 93 94 | - (void)replaceObjectAtIndex: (size_t)index withObject: (id)object { id *objects = [array cArray]; id oldObject; if (index >= [array count]) | | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | - (void)replaceObjectAtIndex: (size_t)index withObject: (id)object { id *objects = [array cArray]; id oldObject; if (index >= [array count]) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; oldObject = objects[index]; objects[index] = [object retain]; [oldObject release]; } - (void)replaceObjectIdenticalTo: (id)oldObject |
︙ | ︙ | |||
174 175 176 177 178 179 180 | - (void)removeObjectsInRange: (of_range_t)range { id *objects = [array cArray], *copy; size_t i, count = [array count]; if (range.length > count - range.start) | | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | - (void)removeObjectsInRange: (of_range_t)range { id *objects = [array cArray], *copy; size_t i, count = [array count]; if (range.length > count - range.start) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; copy = [self allocMemoryWithSize: sizeof(*copy) count: range.length]; memcpy(copy, objects + range.start, range.length * sizeof(id)); @try { [array removeItemsInRange: range]; |
︙ | ︙ | |||
208 209 210 211 212 213 214 | withObjectAtIndex: (size_t)index2 { id *objects = [array cArray]; size_t count = [array count]; id tmp; if (index1 >= count || index2 >= count) | | | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | withObjectAtIndex: (size_t)index2 { id *objects = [array cArray]; size_t count = [array count]; id tmp; if (index1 >= count || index2 >= count) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; tmp = objects[index1]; objects[index1] = objects[index2]; objects[index2] = tmp; } - (void)reverse |
︙ | ︙ | |||
266 267 268 269 270 271 272 | size_t i, count = [array count]; BOOL stop = NO; unsigned long mutations2 = mutations; for (i = 0; i < count && !stop; i++) { if (mutations != mutations2) @throw [OFEnumerationMutationException | | | | | | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | size_t i, count = [array count]; BOOL stop = NO; unsigned long mutations2 = mutations; for (i = 0; i < count && !stop; i++) { if (mutations != mutations2) @throw [OFEnumerationMutationException exceptionWithClass: [self class] object: self]; block(objects[i], i, &stop); } } - (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block { id *objects = [array cArray]; size_t i, count = [array count]; BOOL stop = NO; unsigned long mutations2 = mutations; for (i = 0; i < count && !stop; i++) { id newObject; if (mutations != mutations2) @throw [OFEnumerationMutationException exceptionWithClass: [self class] object: self]; newObject = block(objects[i], i, &stop); if (newObject == nil) @throw [OFInvalidArgumentException exceptionWithClass: [self class] selector: _cmd]; [newObject retain]; [objects[i] release]; objects[i] = newObject; } } #endif - (void)makeImmutable { object_setClass(self, [OFArray_adjacent class]); } @end |