@@ -34,34 +34,30 @@ [objs[i] retain]; return new; } -- addObject: (OFObject*)obj +- (void)addObject: (OFObject*)obj { [array addItem: &obj]; [obj retain]; mutations++; - - return self; } -- addObject: (OFObject*)obj - atIndex: (size_t)index +- (void)addObject: (OFObject*)obj + atIndex: (size_t)index { [array addItem: &obj atIndex: index]; [obj retain]; mutations++; - - return self; } -- replaceObject: (OFObject*)old - withObject: (OFObject*)new +- (void)replaceObject: (OFObject*)old + withObject: (OFObject*)new { OFObject **objs = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { @@ -69,31 +65,29 @@ [new retain]; [objs[i] release]; objs[i] = new; } } - - return self; } -- replaceObjectAtIndex: (size_t)index - withObject: (OFObject*)obj +- (id)replaceObjectAtIndex: (size_t)index + withObject: (OFObject*)obj { OFObject **objs = [array cArray]; + id old; if (index >= [array count]) @throw [OFOutOfRangeException newWithClass: isa]; - [obj retain]; - [objs[index] release]; - objs[index] = obj; + old = objs[index]; + objs[index] = [obj retain]; - return self; + return [old autorelease]; } -- replaceObjectIdenticalTo: (OFObject*)old - withObject: (OFObject*)new +- (void)replaceObjectIdenticalTo: (OFObject*)old + withObject: (OFObject*)new { OFObject **objs = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { @@ -101,15 +95,13 @@ [new retain]; [objs[i] release]; objs[i] = new; } } - - return self; } -- removeObject: (OFObject*)obj +- (void)removeObject: (OFObject*)obj { OFObject **objs = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { @@ -132,15 +124,13 @@ objs = [array cArray]; count--; i--; } } - - return self; } -- removeObjectIdenticalTo: (OFObject*)obj +- (void)removeObjectIdenticalTo: (OFObject*)obj { OFObject **objs = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { @@ -161,21 +151,23 @@ objs = [array cArray]; count--; i--; } } - - return self; } -- removeObjectAtIndex: (size_t)index +- (id)removeObjectAtIndex: (size_t)index { - return [self removeNObjects: 1 - atIndex: index]; + id old = [self objectAtIndex: index]; + + [self removeNObjects: 1 + atIndex: index]; + + return old; } -- removeNObjects: (size_t)nobjects +- (void)removeNObjects: (size_t)nobjects { OFObject **objs = [array cArray], **copy; size_t i, count = [array count]; if (nobjects > count) @@ -192,16 +184,14 @@ for (i = 0; i < nobjects; i++) [copy[i] release]; } @finally { [self freeMemory: copy]; } - - return self; } -- removeNObjects: (size_t)nobjects - atIndex: (size_t)index +- (void)removeNObjects: (size_t)nobjects + atIndex: (size_t)index { OFObject **objs = [array cArray], **copy; size_t i, count = [array count]; if (nobjects > count - index) @@ -219,12 +209,10 @@ for (i = 0; i < nobjects; i++) [copy[i] release]; } @finally { [self freeMemory: copy]; } - - return self; } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count_