ObjFW  Diff

Differences From Artifact [cd027f3f1d]:

To Artifact [c66c422e10]:


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
102
103
104
105
106
107
108
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
142
143
144
145
146
147
148
149

150
151
152
153
154
155
156
157
158

159
160
161
162
163


164
165

166
167
168
169
170
171
172
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
102
103
104
105
106
107
108
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
142
143



144
145
146

147
148
149
150
151
152
153
154







+
+




-
-
+
+









-
-
+













+
+


















-
-
-
-
-
-
-
+
-
-
-
-
















-
-
-
-
-
-
-
+
-
-
-
-




-
+


-
-
-
+
+

-
+







	size_t i, count = [array count];

	for (i = 0; i < count; i++) {
		if ([objs[i] isEqual: old]) {
			[new retain];
			[objs[i] release];
			objs[i] = new;

			return;
		}
	}
}

- (id)replaceObjectAtIndex: (size_t)index
		withObject: (id)obj
- (void)replaceObjectAtIndex: (size_t)index
		  withObject: (id)obj
{
	id *objs = [array cArray];
	id old;

	if (index >= [array count])
		@throw [OFOutOfRangeException newWithClass: isa];

	old = objs[index];
	objs[index] = [obj retain];

	return [old autorelease];
	[old release];
}

- (void)replaceObjectIdenticalTo: (id)old
		      withObject: (id)new
{
	id *objs = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++) {
		if (objs[i] == old) {
			[new retain];
			[objs[i] release];
			objs[i] = new;

			return;
		}
	}
}

- (void)removeObject: (id)obj
{
	id *objs = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++) {
		if ([objs[i] isEqual: obj]) {
			id obj = objs[i];

			[array removeItemAtIndex: i];
			mutations++;

			[obj release];

			/*
			 * We need to get the C array again as it might have
			 * been relocated. We also need to adjust the count
			 * as otherwise we would have an out of bounds access.
			 * As another object will be at the current index now,
			 * we also need to handle the same index again, thus we
			 * decrease it.
			return;
			 */
			objs = [array cArray];
			count--;
			i--;
		}
	}
}

- (void)removeObjectIdenticalTo: (id)obj
{
	id *objs = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++) {
		if (objs[i] == obj) {
			[array removeItemAtIndex: i];
			mutations++;

			[obj release];

			/*
			 * We need to get the C array again as it might have
			 * been relocated. We also need to adjust the count
			 * as otherwise we would have an out of bounds access.
			 * As another object will be at the current index now,
			 * we also need to handle the same index again, thus we
			 * decrease it.
			return;
			 */
			objs = [array cArray];
			count--;
			i--;
		}
	}
}

- (id)removeObjectAtIndex: (size_t)index
- (void)removeObjectAtIndex: (size_t)index
{
	id old = [self objectAtIndex: index];

	[self removeNObjects: 1
		     atIndex: index];
	[array removeItemAtIndex: index];
	[old release];

	return old;
	mutations++;
}

- (void)removeNObjects: (size_t)nobjects
{
	id *objs = [array cArray], *copy;
	size_t i, count = [array count];