14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
|
*/
#include "config.h"
#include <stdlib.h>
#import "OFMutableSet.h"
#import "OFMutableMapTableSet.h"
#import "OFString.h"
static struct {
Class isa;
} placeholder;
@interface OFMutableSetPlaceholder: OFMutableSet
@end
@implementation OFMutableSetPlaceholder
- (instancetype)init
{
return (id)[[OFMutableMapTableSet alloc] init];
}
- (instancetype)initWithSet: (OFSet *)set
{
return (id)[[OFMutableMapTableSet alloc] initWithSet: set];
}
- (instancetype)initWithArray: (OFArray *)array
{
return (id)[[OFMutableMapTableSet alloc] initWithArray: array];
}
- (instancetype)initWithObjects: (id)firstObject, ...
{
id ret;
va_list arguments;
va_start(arguments, firstObject);
ret = [[OFMutableMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
{
return (id)[[OFMutableMapTableSet alloc] initWithObjects: objects
count: count];
}
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
return (id)[[OFMutableMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
}
- (instancetype)initWithCapacity: (size_t)capacity
{
return (id)[[OFMutableMapTableSet alloc] initWithCapacity: capacity];
}
OF_SINGLETON_METHODS
@end
@implementation OFMutableSet
+ (void)initialize
{
if (self == [OFMutableSet class])
object_setClass((id)&placeholder,
[OFMutableSetPlaceholder class]);
}
+ (instancetype)alloc
{
if (self == [OFMutableSet class])
return (id)&placeholder;
|
|
|
|
|
|
|
|
|
|
|
|
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
|
*/
#include "config.h"
#include <stdlib.h>
#import "OFMutableSet.h"
#import "OFConcreteMutableSet.h"
#import "OFString.h"
static struct {
Class isa;
} placeholder;
@interface OFPlaceholderMutableSet: OFMutableSet
@end
@implementation OFPlaceholderMutableSet
- (instancetype)init
{
return (id)[[OFConcreteMutableSet alloc] init];
}
- (instancetype)initWithSet: (OFSet *)set
{
return (id)[[OFConcreteMutableSet alloc] initWithSet: set];
}
- (instancetype)initWithArray: (OFArray *)array
{
return (id)[[OFConcreteMutableSet alloc] initWithArray: array];
}
- (instancetype)initWithObjects: (id)firstObject, ...
{
id ret;
va_list arguments;
va_start(arguments, firstObject);
ret = [[OFConcreteMutableSet alloc] initWithObject: firstObject
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
{
return (id)[[OFConcreteMutableSet alloc] initWithObjects: objects
count: count];
}
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
return (id)[[OFConcreteMutableSet alloc] initWithObject: firstObject
arguments: arguments];
}
- (instancetype)initWithCapacity: (size_t)capacity
{
return (id)[[OFConcreteMutableSet alloc] initWithCapacity: capacity];
}
OF_SINGLETON_METHODS
@end
@implementation OFMutableSet
+ (void)initialize
{
if (self == [OFMutableSet class])
object_setClass((id)&placeholder,
[OFPlaceholderMutableSet class]);
}
+ (instancetype)alloc
{
if (self == [OFMutableSet class])
return (id)&placeholder;
|