Differences From Artifact [40b1b9e5f0]:
- File
src/OFMutableAdjacentArray.m
— part of check-in
[627511b032]
at
2020-11-14 12:23:55
on branch trunk
— Rename of_malloc and of_calloc
The new names should be more accurate. (user: js, size: 7772) [annotate] [blame] [check-ins using] [more...]
To Artifact [7c769150fe]:
- File src/OFMutableAdjacentArray.m — part of check-in [1b82d3bf4f] at 2021-03-07 20:25:21 on branch trunk — *.m: Fold methods into one line where it fits (user: js, size: 7625) [annotate] [blame] [check-ins using] [more...]
1 | /* | < < | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im> * * 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 * the packaging of this file. * |
︙ | ︙ | |||
57 58 59 60 61 62 63 | [_array addItem: &object]; [object retain]; _mutations++; } | | < | < | < | < < | < | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | [_array addItem: &object]; [object retain]; _mutations++; } - (void)insertObject: (id)object atIndex: (size_t)idx { if (object == nil) @throw [OFInvalidArgumentException exception]; @try { [_array insertItem: &object atIndex: idx]; } @catch (OFOutOfRangeException *e) { @throw [OFOutOfRangeException exception]; } [object retain]; _mutations++; } - (void)insertObjectsFromArray: (OFArray *)array atIndex: (size_t)idx { id const *objects = array.objects; size_t count = array.count; @try { [_array insertItems: objects atIndex: idx count: count]; } @catch (OFOutOfRangeException *e) { @throw [OFOutOfRangeException exception]; } for (size_t i = 0; i < count; i++) [objects[i] retain]; _mutations++; } - (void)replaceObject: (id)oldObject withObject: (id)newObject { id *objects; size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; |
︙ | ︙ | |||
117 118 119 120 121 122 123 | objects[i] = newObject; return; } } } | | < | < | 109 110 111 112 113 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 | objects[i] = newObject; return; } } } - (void)replaceObjectAtIndex: (size_t)idx withObject: (id)object { id *objects; id oldObject; if (object == nil) @throw [OFInvalidArgumentException exception]; objects = _array.mutableItems; if (idx >= _array.count) @throw [OFOutOfRangeException exception]; oldObject = objects[idx]; objects[idx] = [object retain]; [oldObject release]; } - (void)replaceObjectIdenticalTo: (id)oldObject withObject: (id)newObject { id *objects; size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; |
︙ | ︙ | |||
270 271 272 273 274 275 276 | [_array removeLastItem]; [object release]; _mutations++; #endif } | | < | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | [_array removeLastItem]; [object release]; _mutations++; #endif } - (void)exchangeObjectAtIndex: (size_t)idx1 withObjectAtIndex: (size_t)idx2 { id *objects = _array.mutableItems; size_t count = _array.count; id tmp; if (idx1 >= count || idx2 >= count) @throw [OFOutOfRangeException exception]; |
︙ | ︙ |