ObjFW  Check-in [5e98e61531]

Overview
Comment:Add +[OFSet setWithObjects:count:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5e98e615312ea70175cf397cfda5e6aeeab2e63bd2cc0d27cb12075380d2e165
User & Date: js on 2012-03-28 09:25:40
Other Links: manifest | tags
Context
2012-03-29
07:57
Add a few "const" where they make sense. check-in: 89d53f2a9a user: js tags: trunk
2012-03-28
09:25
Add +[OFSet setWithObjects:count:]. check-in: 5e98e61531 user: js tags: trunk
2012-03-27
09:54
Update buildsys. check-in: bd6de09bbd user: js tags: trunk
Changes

Modified src/OFCountedSet.m from [45cb1d890f] to [6fbc6bd897].

56
57
58
59
60
61
62







63
64
65
66
67
68
69
	va_start(arguments, firstObject);
	ret = [[OFCountedSet_hashtable alloc] initWithObject: firstObject
						   arguments: arguments];
	va_end(arguments);

	return ret;
}








- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	return (id)[[OFCountedSet_hashtable alloc] initWithObject: firstObject
							arguments: arguments];
}







>
>
>
>
>
>
>







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
	va_start(arguments, firstObject);
	ret = [[OFCountedSet_hashtable alloc] initWithObject: firstObject
						   arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithObjects: (id*)objects
	    count: (size_t)count
{
	return (id)[[OFCountedSet_hashtable alloc] initWithObjects: objects
							     count: count];
}

- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	return (id)[[OFCountedSet_hashtable alloc] initWithObject: firstObject
							arguments: arguments];
}

Modified src/OFCountedSet_hashtable.m from [fed71ad63c] to [1e8e3d5e5e].

79
80
81
82
83
84
85


















86
87
88
89
90
91
92
- initWithArray: (OFArray*)array
{
	self = [self init];

	@try {
		id *objects = [array objects];
		size_t i, count = [array count];



















		for (i = 0; i < count; i++)
			[self addObject: objects[i]];
	} @catch (id e) {
		[self release];
		@throw e;
	}







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







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
- initWithArray: (OFArray*)array
{
	self = [self init];

	@try {
		id *objects = [array objects];
		size_t i, count = [array count];

		for (i = 0; i < count; i++)
			[self addObject: objects[i]];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithObjects: (id*)objects
	    count: (size_t)count
{
	self = [self init];

	@try {
		size_t i;

		for (i = 0; i < count; i++)
			[self addObject: objects[i]];
	} @catch (id e) {
		[self release];
		@throw e;
	}

Modified src/OFMutableSet.m from [309a28b5d0] to [be374057b2].

55
56
57
58
59
60
61







62
63
64
65
66
67
68
	va_start(arguments, firstObject);
	ret = [[OFMutableSet_hashtable alloc] initWithObject: firstObject
						   arguments: arguments];
	va_end(arguments);

	return ret;
}








- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	return (id)[[OFMutableSet_hashtable alloc] initWithObject: firstObject
							arguments: arguments];
}







>
>
>
>
>
>
>







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
	va_start(arguments, firstObject);
	ret = [[OFMutableSet_hashtable alloc] initWithObject: firstObject
						   arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithObjects: (id*)objects
	    count: (size_t)count
{
	return (id)[[OFMutableSet_hashtable alloc] initWithObjects: objects
							     count: count];
}

- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	return (id)[[OFMutableSet_hashtable alloc] initWithObject: firstObject
							arguments: arguments];
}

Modified src/OFSet.h from [889864d837] to [3339e4633d].

66
67
68
69
70
71
72










73
74
75
76
77
78
79
 * \brief Creates a new set with the specified objects.
 *
 * \param firstObject The first object for the set
 * \return A new, autoreleased set with the specified objects
 */
+ setWithObjects: (id)firstObject, ...;











/**
 * \brief Initializes an already allocated set with the specified set.
 *
 * \param set The set to initialize the set with
 * \return An initialized set with the specified set
 */
- initWithSet: (OFSet*)set;







>
>
>
>
>
>
>
>
>
>







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
 * \brief Creates a new set with the specified objects.
 *
 * \param firstObject The first object for the set
 * \return A new, autoreleased set with the specified objects
 */
+ setWithObjects: (id)firstObject, ...;

/**
 * \brief Creates a new set with the specified objects.
 *
 * \param objects An array of objects for the set
 * \param count The number of objects in the specified array
 * \return A new, autoreleased set with the specified objects
 */
+ setWithObjects: (id*)objects
	   count: (size_t)count;

/**
 * \brief Initializes an already allocated set with the specified set.
 *
 * \param set The set to initialize the set with
 * \return An initialized set with the specified set
 */
- initWithSet: (OFSet*)set;
90
91
92
93
94
95
96










97
98
99
100
101
102
103
 * \brief Initializes an already allocated set with the specified objects.
 *
 * \param firstObject The first object for the set
 * \return An initialized set with the specified objects
 */
- initWithObjects: (id)firstObject, ...;











/**
 * \brief Initializes an already allocated set with the specified object and
 *	  va_list.
 *
 * \param firstObject The first object for the set
 * \param arguments A va_list with the other objects
 * \return An initialized set with the specified object and va_list







>
>
>
>
>
>
>
>
>
>







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
 * \brief Initializes an already allocated set with the specified objects.
 *
 * \param firstObject The first object for the set
 * \return An initialized set with the specified objects
 */
- initWithObjects: (id)firstObject, ...;

/**
 * \brief Initializes an already allocated set with the specified objects.
 *
 * \param objects An array of objects for the set
 * \param count The number of objects in the specified array
 * \return An initialized set with the specified objects
 */
- initWithObjects: (id*)objects
	    count: (size_t)count;

/**
 * \brief Initializes an already allocated set with the specified object and
 *	  va_list.
 *
 * \param firstObject The first object for the set
 * \param arguments A va_list with the other objects
 * \return An initialized set with the specified object and va_list

Modified src/OFSet.m from [0733c68e31] to [98a694fc77].

55
56
57
58
59
60
61







62
63
64
65
66
67
68
	va_start(arguments, firstObject);
	ret = [[OFSet_hashtable alloc] initWithObject: firstObject
					    arguments: arguments];
	va_end(arguments);

	return ret;
}








- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	return (id)[[OFSet_hashtable alloc] initWithObject: firstObject
						 arguments: arguments];
}







>
>
>
>
>
>
>







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
	va_start(arguments, firstObject);
	ret = [[OFSet_hashtable alloc] initWithObject: firstObject
					    arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithObjects: (id*)objects
	    count: (size_t)count
{
	return (id)[[OFSet_hashtable alloc] initWithObjects: objects
						      count: count];
}

- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	return (id)[[OFSet_hashtable alloc] initWithObject: firstObject
						 arguments: arguments];
}
132
133
134
135
136
137
138







139
140
141
142
143
144
145
	va_start(arguments, firstObject);
	ret = [[[self alloc] initWithObject: firstObject
				  arguments: arguments] autorelease];
	va_end(arguments);

	return ret;
}








- init
{
	if (isa == [OFSet class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException exceptionWithClass: c







>
>
>
>
>
>
>







139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
	va_start(arguments, firstObject);
	ret = [[[self alloc] initWithObject: firstObject
				  arguments: arguments] autorelease];
	va_end(arguments);

	return ret;
}

+ setWithObjects: (id*)objects
	   count: (size_t)count
{
	return [[[self alloc] initWithObjects: objects
					count: count] autorelease];
}

- init
{
	if (isa == [OFSet class]) {
		Class c = isa;
		[self release];
		@throw [OFNotImplementedException exceptionWithClass: c
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179









180
181
182
183
184
185
186
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- (id)initWithObjects:(id)firstObject, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, firstObject);
	ret = [self initWithObject: firstObject
			 arguments: arguments];
	va_end(arguments);

	return ret;
}










- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c







|











>
>
>
>
>
>
>
>
>







175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- (id)initWithObjects: (id)firstObject, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, firstObject);
	ret = [self initWithObject: firstObject
			 arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithObjects: (id*)objects
	    count: (size_t)count
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c

Modified src/OFSet_hashtable.m from [2beeed38e8] to [79c7f9b45c].

78
79
80
81
82
83
84
























85
86
87
88
89
90
91
	self = [self init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFNumber *one = [OFNumber numberWithSize: 1];
		id *objects = [array objects];
		size_t i, count = [array count];

























		for (i = 0; i < count; i++)
			[dictionary _setObject: one
					forKey: objects[i]
				       copyKey: NO];

		[pool release];







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







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
	self = [self init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFNumber *one = [OFNumber numberWithSize: 1];
		id *objects = [array objects];
		size_t i, count = [array count];

		for (i = 0; i < count; i++)
			[dictionary _setObject: one
					forKey: objects[i]
				       copyKey: NO];

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithObjects: (id*)objects
	    count: (size_t)count
{
	self = [self init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFNumber *one = [OFNumber numberWithSize: 1];
		size_t i;

		for (i = 0; i < count; i++)
			[dictionary _setObject: one
					forKey: objects[i]
				       copyKey: NO];

		[pool release];