@@ -1,7 +1,7 @@ /* - * Copyright (c) 2008-2021 Jonathan Schleifer + * Copyright (c) 2008-2022 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -293,16 +293,13 @@ if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; count = self.count; - for (size_t i = 0; i < count; i++) { - if ([[self objectAtIndex: i] isEqual: oldObject]) { + for (size_t i = 0; i < count; i++) + if ([[self objectAtIndex: i] isEqual: oldObject]) [self replaceObjectAtIndex: i withObject: newObject]; - return; - } - } } - (void)replaceObjectIdenticalTo: (id)oldObject withObject: (id)newObject { size_t count; @@ -337,11 +334,13 @@ for (size_t i = 0; i < count; i++) { if ([[self objectAtIndex: i] isEqual: object]) { [self removeObjectAtIndex: i]; - return; + i--; + count--; + continue; } } } - (void)removeObjectIdenticalTo: (id)object @@ -355,11 +354,13 @@ for (size_t i = 0; i < count; i++) { if ([self objectAtIndex: i] == object) { [self removeObjectAtIndex: i]; - return; + i--; + count--; + continue; } } } - (void)removeObjectsInRange: (OFRange)range