Overview
Comment: | Add -[minusSet:] and -[intersectSet:] to OFMutableSet. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
821456272fc2fb9d17b0080fefe16f61 |
User & Date: | js on 2011-07-21 19:17:38 |
Other Links: | manifest | tags |
Context
2011-07-21
| ||
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 | |
19:03 | Add -[allKeys] and -[allObjects] to OFDictionary. check-in: cc87fcff36 user: js tags: trunk | |
Changes
Modified src/OFMutableSet.h from [927b683a17] to [f499a0e97e].
︙ | ︙ | |||
33 34 35 36 37 38 39 40 | /** * \brief Removes the specified object from the set. * * \param object The object to remove from the set */ - (void)removeObject: (id)object; @end | > > > > > > > > > > > > > > > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | /** * \brief Removes the specified object from the set. * * \param object The object to remove from the set */ - (void)removeObject: (id)object; /** * \brief Removes all objects from the receiver that are in the specified set. * * \param set The set whose objects will be removed from the receiver */ - (void)minusSet: (OFSet*)set; /** * \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 |
Modified src/OFMutableSet.m from [4ebb225162] to [9c760ecc6b].
︙ | ︙ | |||
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 | #include "config.h" #define OF_MUTABLE_SET_M #import "OFMutableSet.h" #import "OFDictionary.h" #import "OFNull.h" #import "OFAutoreleasePool.h" @implementation OFMutableSet - (void)addObject: (id)object { [dictionary _setObject: [OFNull null] forKey: object copyKey: NO]; mutations++; } - (void)removeObject: (id)object { [dictionary removeObjectForKey: object]; mutations++; } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count { int ret = [super countByEnumeratingWithState: state objects: objects | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | #include "config.h" #define OF_MUTABLE_SET_M #import "OFMutableSet.h" #import "OFDictionary.h" #import "OFNull.h" #import "OFArray.h" #import "OFAutoreleasePool.h" @implementation OFMutableSet - (void)addObject: (id)object { [dictionary _setObject: [OFNull null] forKey: object copyKey: NO]; mutations++; } - (void)removeObject: (id)object { [dictionary removeObjectForKey: object]; mutations++; } - (void)minusSet: (OFSet*)set { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFEnumerator *enumerator = [set objectEnumerator]; id object; while ((object = [enumerator nextObject]) != nil) [self removeObject: object]; [pool release]; } - (void)intersectSet: (OFSet*)set { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFArray *objects = [dictionary allKeys]; id *cArray = [objects cArray]; 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 { int ret = [super countByEnumeratingWithState: state objects: objects |
︙ | ︙ |
Modified tests/OFSet.m from [daab62c011] to [072c14fa20].
︙ | ︙ | |||
73 74 75 76 77 78 79 80 81 82 83 84 85 86 | ![set1 isSubsetOfSet: mutableSet]); TEST(@"-[intersectsSet:]", [(set2 = [OFSet setWithObjects: @"x", nil]) intersectsSet: set1] && [set1 intersectsSet: set2] && ![([OFSet setWithObjects: @"1", nil]) intersectsSet: set1]); #ifdef OF_HAVE_FAST_ENUMERATION ok = YES; i = 0; for (OFString *s in set1) { switch (i) { case 0: | > > > > > > > > > > > > | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | ![set1 isSubsetOfSet: mutableSet]); TEST(@"-[intersectsSet:]", [(set2 = [OFSet setWithObjects: @"x", nil]) intersectsSet: set1] && [set1 intersectsSet: set2] && ![([OFSet setWithObjects: @"1", nil]) intersectsSet: set1]); TEST(@"-[minusSet:]", R([mutableSet minusSet: ([OFSet setWithObjects: @"x", nil])]) && [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) { case 0: |
︙ | ︙ |