ObjFW  Check-in [f50d7da785]

Overview
Comment:Add +[OFMutableSet setWithCapacity:]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f50d7da785aaebc012802167320b76598684da0936e98010d853223565e2dde5
User & Date: js on 2016-06-05 20:27:27
Other Links: manifest | tags
Context
2016-06-05
20:37
Implement Key Value Coding for OFSet check-in: ef8d57bd4e user: js tags: trunk
20:27
Add +[OFMutableSet setWithCapacity:] check-in: f50d7da785 user: js tags: trunk
20:07
Fix -[OFArray valueForKey:] check-in: 134c19b100 user: js tags: trunk
Changes

Modified src/OFMutableSet.h from [8a891f0a53] to [d89f1cc35c].

27
28
29
30
31
32
33


















34
35
36
37
38
39
40
@interface OFMutableSet <ObjectType>: OFSet <ObjectType>
#else
# ifndef DOXYGEN
#  define ObjectType id
# endif
@interface OFMutableSet: OFSet
#endif


















/*!
 * @brief Adds the specified object to the set.
 *
 * @param object The object to add to the set
 */
- (void)addObject: (ObjectType)object;








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
@interface OFMutableSet <ObjectType>: OFSet <ObjectType>
#else
# ifndef DOXYGEN
#  define ObjectType id
# endif
@interface OFMutableSet: OFSet
#endif
/*!
 * @brief Creates a new OFMutableSet with enough memory to hold the specified
 *	  number of objects.
 *
 * @param capacity The initial capacity for the OFMutableSet
 * @return A new autoreleased OFMutableSet
 */
+ (instancetype)setWithCapacity: (size_t)capacity;

/*!
 * @brief Initializes an already allocated OFMutableSet with enough memory to
 *	  hold the specified number of objects.
 *
 * @param capacity The initial capacity for the OFMutableSet
 * @return An initialized OFMutableSet
 */
- initWithCapacity: (size_t)capacity;

/*!
 * @brief Adds the specified object to the set.
 *
 * @param object The object to add to the set
 */
- (void)addObject: (ObjectType)object;

Modified src/OFMutableSet.m from [0d4018a918] to [fd9f446d87].

74
75
76
77
78
79
80





81
82
83
84
85
86
87
}

- initWithSerialization: (OFXMLElement*)element
{
	return (id)[[OFMutableSet_hashtable alloc]
	    initWithSerialization: element];
}






- retain
{
	return self;
}

- autorelease







>
>
>
>
>







74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
}

- initWithSerialization: (OFXMLElement*)element
{
	return (id)[[OFMutableSet_hashtable alloc]
	    initWithSerialization: element];
}

- initWithCapacity: (size_t)capacity
{
	return (id)[[OFMutableSet_hashtable alloc] initWithCapacity: capacity];
}

- retain
{
	return self;
}

- autorelease
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
+ alloc
{
	if (self == [OFMutableSet class])
		return (id)&placeholder;

	return [super alloc];
}






- init
{
	if (object_getClass(self) == [OFMutableSet class]) {
		@try {
			[self doesNotRecognizeSelector: _cmd];
			abort();
		} @catch (id e) {
			[self release];
			@throw e;
		}
	}

	return [super init];
}






- (void)addObject: (id)object
{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)removeObject: (id)object







>
>
>
>
>















>
>
>
>
>







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
+ alloc
{
	if (self == [OFMutableSet class])
		return (id)&placeholder;

	return [super alloc];
}

+ (instancetype)setWithCapacity: (size_t)capacity
{
	return [[[self alloc] initWithCapacity: capacity] autorelease];
}

- init
{
	if (object_getClass(self) == [OFMutableSet class]) {
		@try {
			[self doesNotRecognizeSelector: _cmd];
			abort();
		} @catch (id e) {
			[self release];
			@throw e;
		}
	}

	return [super init];
}

- initWithCapacity: (size_t)capacity
{
	OF_INVALID_INIT_METHOD
}

- (void)addObject: (id)object
{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)removeObject: (id)object