ObjFW  Check-in [05c71bf58b]

Overview
Comment:Add -[unionSet:] to OFMutableSet.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 05c71bf58beec303e2e7ddaec1e3a4818513b83be90463135c430fb3ef8167b8
User & Date: js on 2011-07-21 19:52:47
Other Links: manifest | tags
Context
2011-07-21
22:01
Add -[reduceUsingBlock:] to OFArray. check-in: 03e89edb42 user: js tags: trunk
19:52
Add -[unionSet:] to OFMutableSet. check-in: 05c71bf58b user: js tags: trunk
19:17
Add -[minusSet:] and -[intersectSet:] to OFMutableSet. check-in: 821456272f user: js tags: trunk
Changes

Modified src/OFMutableSet.h from [f499a0e97e] to [0cfa8bd2d7].

48
49
50
51
52
53
54







55
/**
 * \brief Removes all objects from the receiver that are not in the specified
 *	  set.
 *
 * \param set The set to intersect
 */
- (void)intersectSet: (OFSet*)set;







@end







>
>
>
>
>
>
>

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
 * \brief Removes all objects from the receiver that are not in the specified
 *	  set.
 *
 * \param set The set to intersect
 */
- (void)intersectSet: (OFSet*)set;

/**
 * \brief Creates a union of the receiver and the specified set.
 *
 * \param set The set to create the union with
 */
- (void)unionSet: (OFSet*)set;
@end

Modified src/OFMutableSet.m from [9c760ecc6b] to [77a980e945].

61
62
63
64
65
66
67












68
69
70
71
72
73
74
	size_t count = [objects count];
	size_t i;

	for (i = 0; i < count; i++)
		if (![set containsObject: cArray[i]])
			[self removeObject: cArray[i]];













	[pool release];
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count
{







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







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
	size_t count = [objects count];
	size_t i;

	for (i = 0; i < count; i++)
		if (![set containsObject: cArray[i]])
			[self removeObject: cArray[i]];

	[pool release];
}

- (void)unionSet: (OFSet*)set
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFEnumerator *enumerator = [set objectEnumerator];
	id object;

	while ((object = [enumerator nextObject]) != nil)
		[self addObject: object];

	[pool release];
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count
{

Modified tests/OFSet.m from [072c14fa20] to [7fcfa63b54].

82
83
84
85
86
87
88

89
90

91
92
93
94
95
96
97
	    [mutableSet isEqual: ([OFSet setWithObjects: @"baz", @"bar", nil])])

	TEST(@"-[intersectSet:]",
	    R([mutableSet intersectSet: ([OFSet setWithObjects: @"baz",
	    nil])]) && [mutableSet isEqual: ([OFSet setWithObjects: @"baz",
	    nil])])


	[mutableSet addObject: @"baz"];
	[mutableSet addObject: @"x"];


#ifdef OF_HAVE_FAST_ENUMERATION
	ok = YES;
	i = 0;

	for (OFString *s in set1) {
		switch (i) {







>
|
|
>







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
	    [mutableSet isEqual: ([OFSet setWithObjects: @"baz", @"bar", nil])])

	TEST(@"-[intersectSet:]",
	    R([mutableSet intersectSet: ([OFSet setWithObjects: @"baz",
	    nil])]) && [mutableSet isEqual: ([OFSet setWithObjects: @"baz",
	    nil])])

	TEST(@"-[unionSet:]",
	    R([mutableSet unionSet: ([OFSet setWithObjects: @"x", @"bar",
	    nil])]) && [mutableSet isEqual: ([OFSet setWithObjects: @"baz",
	    @"bar", @"x", nil])])

#ifdef OF_HAVE_FAST_ENUMERATION
	ok = YES;
	i = 0;

	for (OFString *s in set1) {
		switch (i) {