30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
OFMutableSet *_set;
}
@end
@interface SimpleMutableSet: OFMutableSet
{
OFMutableSet *_set;
}
@end
@implementation SimpleSet
- (instancetype)init
{
self = [super init];
|
>
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
OFMutableSet *_set;
}
@end
@interface SimpleMutableSet: OFMutableSet
{
OFMutableSet *_set;
unsigned long _mutations;
}
@end
@implementation SimpleSet
- (instancetype)init
{
self = [super init];
|
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
|
return [_set containsObject: object];
}
- (OFEnumerator *)objectEnumerator
{
return [_set objectEnumerator];
}
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t *)state
objects: (id *)objects
count: (int)count
{
return [_set countByEnumeratingWithState: state
objects: objects
count: count];
}
@end
@implementation SimpleMutableSet
+ (void)initialize
{
if (self == [SimpleMutableSet class])
[self inheritMethodsFromClass: [SimpleSet class]];
}
- (void)addObject: (id)object
{
[_set addObject: object];
}
- (void)removeObject: (id)object
{
[_set removeObject: object];
}
@end
@implementation TestsAppDelegate (OFSetTests)
- (void)setTestsWithClass: (Class)setClass
mutableClass: (Class)mutableSetClass
{
|
<
<
<
<
<
<
<
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
return [_set containsObject: object];
}
- (OFEnumerator *)objectEnumerator
{
return [_set objectEnumerator];
}
@end
@implementation SimpleMutableSet
+ (void)initialize
{
if (self == [SimpleMutableSet class])
[self inheritMethodsFromClass: [SimpleSet class]];
}
- (void)addObject: (id)object
{
bool existed = [self containsObject: object];
[_set addObject: object];
if (existed)
_mutations++;
}
- (void)removeObject: (id)object
{
bool existed = [self containsObject: object];
[_set removeObject: object];
if (existed)
_mutations++;
}
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t *)state
objects: (id *)objects
count: (int)count
{
int ret = [_set countByEnumeratingWithState: state
objects: objects
count: count];
state->mutationsPtr = &_mutations;
return ret;
}
@end
@implementation TestsAppDelegate (OFSetTests)
- (void)setTestsWithClass: (Class)setClass
mutableClass: (Class)mutableSetClass
{
|