Differences From Artifact [725da742e3]:
- File
src/OFMutableArray_adjacent.m
— part of check-in
[26f2ffa908]
at
2012-06-06 12:15:46
on branch trunk
— -[addObject:atIndex:] -> -[insertObject:atIndex:].
For consistency with Foundation. (user: js, size: 6570) [annotate] [blame] [check-ins using]
To Artifact [168c402c93]:
- File
src/OFMutableArray_adjacent.m
— part of check-in
[d5ddb2cb48]
at
2012-06-06 13:09:08
on branch trunk
— Rework OFDataArray API.
Also adds more checks. (user: js, size: 6600) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
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 |
#import "OFArray_adjacent.h"
#import "OFDataArray.h"
#import "OFAutoreleasePool.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
@implementation OFMutableArray_adjacent
+ (void)initialize
{
if (self == [OFMutableArray_adjacent class])
[self inheritMethodsFromClass: [OFArray_adjacent class]];
}
- (void)addObject: (id)object
{
[array addItem: &object];
[object retain];
mutations++;
}
- (void)insertObject: (id)object
atIndex: (size_t)index
{
| > > | | | 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 53 54 55 56 57 58 |
#import "OFArray_adjacent.h"
#import "OFDataArray.h"
#import "OFAutoreleasePool.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
#import "macros.h"
@implementation OFMutableArray_adjacent
+ (void)initialize
{
if (self == [OFMutableArray_adjacent class])
[self inheritMethodsFromClass: [OFArray_adjacent class]];
}
- (void)addObject: (id)object
{
[array addItem: &object];
[object retain];
mutations++;
}
- (void)insertObject: (id)object
atIndex: (size_t)index
{
[array insertItem: &object
atIndex: index];
[object retain];
mutations++;
}
- (void)replaceObject: (id)oldObject
withObject: (id)newObject
|
| ︙ | ︙ | |||
154 155 156 157 158 159 160 |
@throw [OFOutOfRangeException exceptionWithClass: isa];
copy = [self allocMemoryForNItems: nObjects
ofSize: sizeof(id)];
memcpy(copy, objects + (count - nObjects), nObjects * sizeof(id));
@try {
| | > | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
@throw [OFOutOfRangeException exceptionWithClass: isa];
copy = [self allocMemoryForNItems: nObjects
ofSize: sizeof(id)];
memcpy(copy, objects + (count - nObjects), nObjects * sizeof(id));
@try {
[array removeItemsInRange:
of_range(count - nObjects, nObjects)];
mutations++;
for (i = 0; i < nObjects; i++)
[copy[i] release];
} @finally {
[self freeMemory: copy];
}
|
| ︙ | ︙ | |||
188 189 190 191 192 193 194 |
@throw [OFOutOfRangeException exceptionWithClass: isa];
copy = [self allocMemoryForNItems: range.length
ofSize: sizeof(id)];
memcpy(copy, objects + range.start, range.length * sizeof(id));
@try {
| | < | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
@throw [OFOutOfRangeException exceptionWithClass: isa];
copy = [self allocMemoryForNItems: range.length
ofSize: sizeof(id)];
memcpy(copy, objects + range.start, range.length * sizeof(id));
@try {
[array removeItemsInRange: range];
mutations++;
for (i = 0; i < range.length; i++)
[copy[i] release];
} @finally {
[self freeMemory: copy];
}
|
| ︙ | ︙ |