mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +00:00
Merged changes from other author
This commit is contained in:
commit
80843a9e4b
3 changed files with 424 additions and 501 deletions
|
@ -40,14 +40,8 @@
|
|||
#import "GSDispatch.h"
|
||||
#import "GSSorting.h"
|
||||
|
||||
#define GSI_ARRAY_TYPE NSRange
|
||||
#define GSI_ARRAY_NO_RELEASE 0
|
||||
#define GSI_ARRAY_NO_RETAIN 0
|
||||
#define GSI_ARRAY_TYPES GSUNION_OBJ
|
||||
|
||||
#define GSI_ARRAY_RELEASE(A, X) [(X).obj release]
|
||||
#define GSI_ARRAY_RETAIN(A, X) [(X).obj retain]
|
||||
|
||||
#import "GNUstepBase/GSIArray.h"
|
||||
|
||||
@interface GSOrderedSet : NSOrderedSet
|
||||
|
@ -125,7 +119,9 @@
|
|||
GSIArrayItem item;
|
||||
|
||||
if (current == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
item = GSIArrayItemAtIndex(&set->array, --current);
|
||||
return (id)(item.obj);
|
||||
|
@ -230,7 +226,6 @@ static Class mutableSetClass;
|
|||
if (![self containsObject: obj])
|
||||
{
|
||||
GSIArrayAddItem(&array, item);
|
||||
RETAIN(obj);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
|
@ -248,11 +243,6 @@ static Class mutableSetClass;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) addObject: (id)anObject
|
||||
{
|
||||
[self insertObject: anObject atIndex: [self count]];
|
||||
}
|
||||
|
||||
- (void) insertObject: (id)object atIndex: (NSUInteger)index
|
||||
{
|
||||
GSIArrayItem item;
|
||||
|
@ -267,7 +257,6 @@ static Class mutableSetClass;
|
|||
{
|
||||
item.obj = object;
|
||||
GSIArrayInsertItem(&array, item, index);
|
||||
RETAIN(object);
|
||||
_version++;
|
||||
}
|
||||
}
|
||||
|
@ -279,13 +268,6 @@ static Class mutableSetClass;
|
|||
GSIArrayRemoveItemAtIndex(&array, index);
|
||||
}
|
||||
|
||||
- (void) replaceObjectAtIndex: (NSUInteger)index
|
||||
withObject: (id)obj
|
||||
{
|
||||
[self removeObjectAtIndex: index];
|
||||
[self insertObject: obj atIndex: index];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
return [self initWithCapacity: 0];
|
||||
|
@ -329,4 +311,3 @@ static Class mutableSetClass;
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -62,12 +62,9 @@ static Class NSMutableOrderedSet_abstract_class;
|
|||
static Class NSOrderedSet_concrete_class;
|
||||
static Class NSMutableOrderedSet_concrete_class;
|
||||
|
||||
static SEL addSel;
|
||||
static SEL countSel;
|
||||
static SEL eqSel;
|
||||
static SEL oaiSel;
|
||||
static SEL remSel;
|
||||
static SEL rlSel;
|
||||
|
||||
+ (id) allocWithZone: (NSZone*)z
|
||||
{
|
||||
|
@ -87,12 +84,9 @@ static SEL rlSel;
|
|||
{
|
||||
[self setVersion: 1];
|
||||
|
||||
addSel = @selector(addObject:);
|
||||
countSel = @selector(count);
|
||||
eqSel = @selector(isEqual:);
|
||||
oaiSel = @selector(objectAtIndex:);
|
||||
remSel = @selector(removeObjectAtIndex:);
|
||||
rlSel = @selector(removeLastObject);
|
||||
|
||||
NSOrderedSet_abstract_class = self;
|
||||
NSOrderedSet_concrete_class = [GSOrderedSet class];
|
||||
|
@ -100,6 +94,29 @@ static SEL rlSel;
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) _raiseRangeExceptionWithIndex: (NSUInteger)index from: (SEL)sel
|
||||
{
|
||||
NSDictionary *info;
|
||||
NSException *exception;
|
||||
NSString *reason;
|
||||
NSUInteger count = [self count];
|
||||
|
||||
info = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithUnsignedInteger: index], @"Index",
|
||||
[NSNumber numberWithUnsignedInteger: count], @"Count",
|
||||
self, @"GSMutableSet", nil, nil];
|
||||
|
||||
reason = [NSString stringWithFormat:
|
||||
@"Index %"PRIuPTR" is out of range %d (in '%@')",
|
||||
index, count, NSStringFromSelector(sel)];
|
||||
|
||||
exception = [NSException exceptionWithName: NSRangeException
|
||||
reason: reason
|
||||
userInfo: info];
|
||||
[exception raise];
|
||||
}
|
||||
|
||||
- (Class) classForCoder
|
||||
{
|
||||
return NSOrderedSet_abstract_class;
|
||||
|
@ -108,23 +125,6 @@ static SEL rlSel;
|
|||
// NSCoding
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
/*
|
||||
Class c;
|
||||
|
||||
c = object_getClass(self);
|
||||
if (c == NSOrderedSet_abstract_class)
|
||||
{
|
||||
DESTROY(self);
|
||||
self = [NSOrderedSet_concrete_class allocWithZone: NSDefaultMallocZone()];
|
||||
return [self initWithCoder: coder];
|
||||
}
|
||||
else if (c == NSMutableOrderedSet_abstract_class)
|
||||
{
|
||||
DESTROY(self);
|
||||
self = [NSMutableOrderedSet_concrete_class allocWithZone: NSDefaultMallocZone()];
|
||||
return [self initWithCoder: coder];
|
||||
}
|
||||
*/
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
id array;
|
||||
|
@ -265,16 +265,7 @@ static SEL rlSel;
|
|||
*/
|
||||
if (count > 0)
|
||||
{
|
||||
// IMP imp = [self methodForSelector: @selector(objectAtIndex:)];
|
||||
// int i;
|
||||
// int p = state->state;
|
||||
|
||||
|
||||
[self getObjects: stackbuf range: NSMakeRange(state->state, count)];
|
||||
/*for (i = 0; i < count; i++, p++)
|
||||
{
|
||||
stackbuf[i] = (*imp)(self, @selector(objectAtIndex:), p);
|
||||
}*/
|
||||
state->state += count;
|
||||
}
|
||||
else
|
||||
|
@ -520,9 +511,13 @@ static SEL rlSel;
|
|||
while ((o = [e nextObject]))
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
os[i] = [o copy];
|
||||
}
|
||||
else
|
||||
{
|
||||
os[i] = o;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
self = [self initWithObjects: os count: c];
|
||||
|
@ -553,9 +548,13 @@ static SEL rlSel;
|
|||
if (i >= loc && j < len)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
os[i] = [o copy];
|
||||
}
|
||||
else
|
||||
{
|
||||
os[i] = o;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
|
@ -593,9 +592,13 @@ static SEL rlSel;
|
|||
while ((o = [e nextObject]))
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
os[i] = [o copy];
|
||||
}
|
||||
else
|
||||
{
|
||||
os[i] = o;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
self = [self initWithObjects: os count: c];
|
||||
|
@ -686,7 +689,9 @@ static SEL rlSel;
|
|||
{
|
||||
NSUInteger count = [self count];
|
||||
if (count == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
return [self objectAtIndex: 0];
|
||||
}
|
||||
|
||||
|
@ -694,7 +699,9 @@ static SEL rlSel;
|
|||
{
|
||||
NSUInteger count = [self count];
|
||||
if (count == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
return [self objectAtIndex: count - 1];
|
||||
}
|
||||
|
||||
|
@ -1003,14 +1010,18 @@ static SEL rlSel;
|
|||
|
||||
- (void) getObjects: (__unsafe_unretained id[])aBuffer range: (NSRange)aRange
|
||||
{
|
||||
NSUInteger i, j = 0, c = [self count], e = aRange.location + aRange.length;
|
||||
NSUInteger i, j = 0;
|
||||
NSUInteger c = [self count];
|
||||
NSUInteger e = aRange.location + aRange.length;
|
||||
IMP get = [self methodForSelector: oaiSel];
|
||||
|
||||
GS_RANGE_CHECK(aRange, c);
|
||||
|
||||
for (i = aRange.location; i < e; i++)
|
||||
{
|
||||
aBuffer[j++] = (*get)(self, oaiSel, i);
|
||||
}
|
||||
}
|
||||
|
||||
// Key-Value Observing Support
|
||||
|
||||
|
@ -1019,41 +1030,32 @@ static SEL rlSel;
|
|||
options: (NSKeyValueObservingOptions)options
|
||||
context: (void *)context
|
||||
{
|
||||
NSException *exception = nil;
|
||||
NSString *reason = @"NSOrderedSet does not support KVO";
|
||||
exception = [NSException exceptionWithName: NSGenericException
|
||||
reason: reason
|
||||
userInfo: nil];
|
||||
[exception raise];
|
||||
[[NSException exceptionWithName: NSGenericException
|
||||
reason: @"NSOrderedSet does not support KVO"
|
||||
userInfo: nil] raise];
|
||||
}
|
||||
|
||||
- (void) removeObserver: (NSObject *)observer
|
||||
forKeyPath: (NSString *)keyPath
|
||||
{
|
||||
NSException *exception = nil;
|
||||
NSString *reason = @"NSOrderedSet does not support KVO";
|
||||
exception = [NSException exceptionWithName: NSGenericException
|
||||
reason: reason
|
||||
userInfo: nil];
|
||||
[exception raise];
|
||||
[[NSException exceptionWithName: NSGenericException
|
||||
reason: @"NSOrderedSet does not support KVO"
|
||||
userInfo: nil] raise];
|
||||
}
|
||||
|
||||
- (void) removeObserver: (NSObject *)observer
|
||||
forKeyPath: (NSString *)keyPath
|
||||
context: (void *)context
|
||||
{
|
||||
NSException *exception = nil;
|
||||
NSString *reason = @"NSOrderedSet does not support KVO";
|
||||
exception = [NSException exceptionWithName: NSGenericException
|
||||
reason: reason
|
||||
userInfo: nil];
|
||||
[exception raise];
|
||||
[[NSException exceptionWithName: NSGenericException
|
||||
reason: @"NSOrderedSet does not support KVO"
|
||||
userInfo: nil] raise];
|
||||
}
|
||||
|
||||
// Key value coding support
|
||||
- (void) setValue: (id)value forKey: (NSString*)key
|
||||
{
|
||||
volatile id object = nil;
|
||||
id object;
|
||||
NSEnumerator *e = [self objectEnumerator];
|
||||
|
||||
while ((object = [e nextObject]) != nil)
|
||||
|
@ -1066,7 +1068,7 @@ static SEL rlSel;
|
|||
- (id) valueForKey: (NSString*)key
|
||||
{
|
||||
NSEnumerator *e = [self objectEnumerator];
|
||||
id object = nil;
|
||||
id object;
|
||||
NSMutableSet *results = [NSMutableSet setWithCapacity: [self count]];
|
||||
|
||||
while ((object = [e nextObject]) != nil)
|
||||
|
@ -1074,7 +1076,9 @@ static SEL rlSel;
|
|||
id result = [object valueForKey: key];
|
||||
|
||||
if (result == nil)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
[results addObject: result];
|
||||
}
|
||||
|
@ -1101,15 +1105,18 @@ static SEL rlSel;
|
|||
- (BOOL) isEqual: (id)other
|
||||
{
|
||||
if ([other isKindOfClass: [NSOrderedSet class]])
|
||||
{
|
||||
return [self isEqualToOrderedSet: other];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Set operations
|
||||
- (BOOL) intersectsOrderedSet: (NSOrderedSet *)otherSet
|
||||
{
|
||||
id o = nil;
|
||||
NSEnumerator *e = nil;
|
||||
id o;
|
||||
NSEnumerator *e;
|
||||
|
||||
// -1. If this set is empty, this method should return NO.
|
||||
if ([self count] == 0)
|
||||
|
@ -1146,7 +1153,7 @@ static SEL rlSel;
|
|||
|
||||
- (BOOL) isSubsetOfOrderedSet: (NSOrderedSet *)otherSet
|
||||
{
|
||||
id so = nil, oo = nil;
|
||||
id so, oo;
|
||||
NSEnumerator *selfEnum = [self objectEnumerator];
|
||||
NSEnumerator *otherEnum = [otherSet objectEnumerator];
|
||||
NSUInteger l = [self count];
|
||||
|
@ -1181,19 +1188,30 @@ static SEL rlSel;
|
|||
|
||||
- (BOOL) isSubsetOfSet: (NSSet *)otherSet
|
||||
{
|
||||
id o = nil, e = nil;
|
||||
id o, e;
|
||||
NSUInteger l = [self count];
|
||||
|
||||
// -1. If this set is empty, this method should return NO.
|
||||
if ([self count] == 0)
|
||||
return NO;
|
||||
|
||||
// 0. Loop for all members in otherSet
|
||||
e = [otherSet objectEnumerator];
|
||||
while ((o = [e nextObject])) // 1. pick a member from otherSet.
|
||||
// -1. If this set is empty, this method should return YES.
|
||||
if (l == 0)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
// If count of set is more than otherSet it's not a subset
|
||||
if (l > [otherSet count])
|
||||
{
|
||||
if ([self containsObject: o] == NO) // 2. check the member is in this set(self).
|
||||
return NO;
|
||||
}
|
||||
|
||||
// 0. Loop for all members in self
|
||||
e = [self objectEnumerator];
|
||||
while ((o = [e nextObject])) // 1. pick a member from self.
|
||||
{
|
||||
if ([otherSet containsObject: o] == NO) // 2. check the member is in otherset.
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES; // if all members are in set.
|
||||
}
|
||||
|
||||
|
@ -1319,28 +1337,6 @@ static SEL rlSel;
|
|||
return NSMutableOrderedSet_abstract_class;
|
||||
}
|
||||
|
||||
- (void) _raiseRangeExceptionWithIndex: (NSUInteger)index from: (SEL)sel
|
||||
{
|
||||
NSDictionary *info;
|
||||
NSException *exception;
|
||||
NSString *reason;
|
||||
NSUInteger count = [self count];
|
||||
|
||||
info = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithUnsignedInteger: index], @"Index",
|
||||
[NSNumber numberWithUnsignedInteger: count], @"Count",
|
||||
self, @"GSMutableSet", nil, nil];
|
||||
|
||||
reason = [NSString stringWithFormat:
|
||||
@"Index %"PRIuPTR" is out of range %d (in '%@')",
|
||||
index, count, NSStringFromSelector(sel)];
|
||||
|
||||
exception = [NSException exceptionWithName: NSRangeException
|
||||
reason: reason
|
||||
userInfo: info];
|
||||
[exception raise];
|
||||
}
|
||||
|
||||
- (instancetype) initWithCapacity: (NSUInteger)capacity
|
||||
{
|
||||
self = [self init];
|
||||
|
@ -1359,7 +1355,7 @@ static SEL rlSel;
|
|||
|
||||
- (void) addObject: (id)anObject
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
[self insertObject: anObject atIndex: [self count]];
|
||||
}
|
||||
|
||||
- (void) addObjects: (const id[])objects count: (NSUInteger)count
|
||||
|
@ -1415,45 +1411,18 @@ static SEL rlSel;
|
|||
|
||||
- (void) removeObject: (id)anObject
|
||||
{
|
||||
NSUInteger i;
|
||||
NSUInteger index;
|
||||
|
||||
if (anObject == nil)
|
||||
{
|
||||
NSWarnMLog(@"attempt to remove nil object");
|
||||
return;
|
||||
}
|
||||
i = [self count];
|
||||
if (i > 0)
|
||||
{
|
||||
IMP rem = 0;
|
||||
IMP get = [self methodForSelector: oaiSel];
|
||||
BOOL (*eq)(id, SEL, id)
|
||||
= (BOOL (*)(id, SEL, id))[anObject methodForSelector: eqSel];
|
||||
|
||||
while (i-- > 0)
|
||||
index = [self indexOfObject: anObject];
|
||||
if (NSNotFound != index)
|
||||
{
|
||||
id o = (*get)(self, oaiSel, i);
|
||||
|
||||
if (o == anObject || (*eq)(anObject, eqSel, o) == YES)
|
||||
{
|
||||
if (rem == 0)
|
||||
{
|
||||
rem = [self methodForSelector: remSel];
|
||||
/*
|
||||
* We need to retain the object so that when we remove the
|
||||
* first equal object we don't get left with a bad object
|
||||
* pointer for later comparisons.
|
||||
*/
|
||||
// RETAIN(anObject);
|
||||
}
|
||||
(*rem)(self, remSel, i);
|
||||
break; // since this is a set we should only have one copy...
|
||||
}
|
||||
}
|
||||
//if (rem != 0)
|
||||
// {
|
||||
// RELEASE(anObject);
|
||||
// }
|
||||
[self removeObjectAtIndex: index];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1462,61 +1431,6 @@ static SEL rlSel;
|
|||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
/*
|
||||
- (void) _removeObjectsFromIndices: (NSUInteger*)indices
|
||||
numIndices: (NSUInteger)count
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
NSUInteger to = 0;
|
||||
NSUInteger from = 0;
|
||||
NSUInteger i;
|
||||
GS_BEGINITEMBUF(sorted, count, NSUInteger);
|
||||
|
||||
while (from < count)
|
||||
{
|
||||
NSUInteger val = indices[from++];
|
||||
|
||||
i = to;
|
||||
while (i > 0 && sorted[i-1] > val)
|
||||
{
|
||||
i--;
|
||||
}
|
||||
if (i == to)
|
||||
{
|
||||
sorted[to++] = val;
|
||||
}
|
||||
else if (sorted[i] != val)
|
||||
{
|
||||
NSUInteger j = to++;
|
||||
|
||||
if (sorted[i] < val)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
while (j > i)
|
||||
{
|
||||
sorted[j] = sorted[j-1];
|
||||
j--;
|
||||
}
|
||||
sorted[i] = val;
|
||||
}
|
||||
}
|
||||
|
||||
if (to > 0)
|
||||
{
|
||||
IMP rem = [self methodForSelector: remSel];
|
||||
|
||||
while (to--)
|
||||
{
|
||||
(*rem)(self, remSel, sorted[to]);
|
||||
}
|
||||
}
|
||||
GS_ENDITEMBUF();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
- (void) _removeObjectsFromIndices: (NSUInteger*)indices
|
||||
numIndices: (NSUInteger)count
|
||||
{
|
||||
|
@ -1542,8 +1456,15 @@ static SEL rlSel;
|
|||
maxCount: count
|
||||
inIndexRange: NULL];
|
||||
|
||||
[self _removeObjectsFromIndices: indexArray
|
||||
numIndices: count];
|
||||
if (count > 0)
|
||||
{
|
||||
IMP rem = [self methodForSelector: remSel];
|
||||
|
||||
while (count--)
|
||||
{
|
||||
(*rem)(self, remSel, indexArray[count]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) removeObjectsInArray: (NSArray *)otherArray
|
||||
|
@ -1570,7 +1491,9 @@ static SEL rlSel;
|
|||
i = aRange.location + aRange.length;
|
||||
|
||||
if (c < i)
|
||||
{
|
||||
i = c;
|
||||
}
|
||||
|
||||
if (i > s)
|
||||
{
|
||||
|
@ -1596,10 +1519,11 @@ static SEL rlSel;
|
|||
}
|
||||
}
|
||||
|
||||
- (void)replaceObjectAtIndex:(NSUInteger)index // required override...
|
||||
- (void) replaceObjectAtIndex: (NSUInteger)index
|
||||
withObject: (id)object
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
[self removeObjectAtIndex: index];
|
||||
[self insertObject: object atIndex: index];
|
||||
}
|
||||
|
||||
- (void) replaceObjectsAtIndexes: (NSIndexSet *)indexes
|
||||
|
@ -1633,8 +1557,11 @@ static SEL rlSel;
|
|||
NSUInteger i = count;
|
||||
|
||||
if (count < (aRange.location + aRange.length))
|
||||
{
|
||||
[NSException raise: NSRangeException
|
||||
format: @"Replacing objects beyond end of const[] id."];
|
||||
}
|
||||
|
||||
[self removeObjectsInRange: aRange];
|
||||
|
||||
while (i-- > 0)
|
||||
|
@ -1696,7 +1623,6 @@ static SEL rlSel;
|
|||
withObjectAtIndex: (NSUInteger)otherIndex
|
||||
{
|
||||
NSUInteger count = [self count];
|
||||
|
||||
if (index >= count)
|
||||
{
|
||||
[self _raiseRangeExceptionWithIndex: index from: _cmd];
|
||||
|
@ -1707,28 +1633,26 @@ static SEL rlSel;
|
|||
}
|
||||
if (index != otherIndex)
|
||||
{
|
||||
NSUInteger min = 0, max = 0;
|
||||
id tmpMax = nil, tmpMin = nil;
|
||||
NSUInteger low, high;
|
||||
id obj1, obj2;
|
||||
|
||||
if (index > otherIndex)
|
||||
{
|
||||
min = otherIndex;
|
||||
max = index;
|
||||
high = index;
|
||||
low = otherIndex;
|
||||
}
|
||||
else // since we know they are not equal
|
||||
else
|
||||
{
|
||||
min = index;
|
||||
max = otherIndex;
|
||||
high = otherIndex;
|
||||
low = index;
|
||||
}
|
||||
|
||||
tmpMax = [self objectAtIndex: max];
|
||||
[self removeObjectAtIndex: max];
|
||||
tmpMin = [self objectAtIndex: min];
|
||||
[self removeObjectAtIndex: min];
|
||||
|
||||
// Exchange objects...
|
||||
[self insertObject: tmpMax atIndex: min];
|
||||
[self insertObject: tmpMin atIndex: max];
|
||||
obj1 = [self objectAtIndex: low];
|
||||
obj2 = [self objectAtIndex: high];
|
||||
[self removeObjectAtIndex: high];
|
||||
[self removeObjectAtIndex: low];
|
||||
[self insertObject: obj2 atIndex: low];
|
||||
[self insertObject: obj1 atIndex: high];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1806,7 +1730,7 @@ static SEL rlSel;
|
|||
[self removeAllObjects];
|
||||
[self addObjectsFromArray: res];
|
||||
|
||||
// RELEASE(res);
|
||||
RELEASE(res);
|
||||
GS_ENDIDBUF();
|
||||
}
|
||||
}
|
||||
|
@ -1815,6 +1739,7 @@ static SEL rlSel;
|
|||
options: (NSSortOptions)options
|
||||
usingComparator: (NSComparator)comparator
|
||||
{
|
||||
// FIXME: Implementation missing
|
||||
}
|
||||
|
||||
- (void) intersectOrderedSet: (NSOrderedSet *)other
|
||||
|
|
|
@ -122,6 +122,7 @@ int main()
|
|||
NSMutableOrderedSet *mutableTest1, *mutableTest2;
|
||||
NSMutableArray *testObjs = [NSMutableArray new];
|
||||
NSData *data = [stringData dataUsingEncoding: NSUTF8StringEncoding];
|
||||
NSMutableSet *testSet;
|
||||
|
||||
testObj = [NSOrderedSet new];
|
||||
[testObjs addObject: testObj];
|
||||
|
@ -145,12 +146,6 @@ int main()
|
|||
PASS(testObj != nil && [testObj count] == 1,
|
||||
"cannot create an ordered set with multiple like elements");
|
||||
|
||||
id objs2[] = {@"Hello"};
|
||||
testObj = [NSOrderedSet orderedSetWithObjects: objs2 count: 2];
|
||||
[testObjs addObject: testObj];
|
||||
PASS(testObj != nil && [testObj count] == 1,
|
||||
"Does not throw exception when count != to number of elements");
|
||||
|
||||
NSMutableArray *arr = [NSMutableArray array];
|
||||
[arr addObject: @"Hello"];
|
||||
[arr addObject: @"World"];
|
||||
|
@ -228,6 +223,13 @@ int main()
|
|||
PASS(isSubset,
|
||||
"mutableTest2 is subset of mutableTest1");
|
||||
|
||||
testSet = [NSMutableSet set];
|
||||
[testSet addObject: o7];
|
||||
[testSet addObject: o8];
|
||||
isSubset = [mutableTest2 isSubsetOfSet: testSet];
|
||||
PASS(isSubset,
|
||||
"mutableTest2 is subset of testSet");
|
||||
|
||||
id o9 = @"Hello";
|
||||
id o10 = @"World";
|
||||
id o11 = @"Ready";
|
||||
|
@ -242,6 +244,12 @@ int main()
|
|||
PASS(isSubset == NO,
|
||||
"mutableTest2 is not subset of mutableTest1");
|
||||
|
||||
testSet = [NSMutableSet set];
|
||||
[testSet addObject: o9];
|
||||
isSubset = [mutableTest2 isSubsetOfSet: testSet];
|
||||
PASS(isSubset == NO,
|
||||
"mutableTest2 is not subset of testSet");
|
||||
|
||||
o9 = @"Hello";
|
||||
o10 = @"World";
|
||||
o11 = @"Ready";
|
||||
|
@ -260,6 +268,15 @@ int main()
|
|||
PASS(isSubset,
|
||||
"mutableTest2 is subset of mutableTest1");
|
||||
|
||||
testSet = [NSMutableSet set];
|
||||
[testSet addObject: o9];
|
||||
[testSet addObject: o10];
|
||||
[testSet addObject: o12];
|
||||
[testSet addObject: o11];
|
||||
isSubset = [mutableTest2 isSubsetOfSet: testSet];
|
||||
PASS(isSubset,
|
||||
"mutableTest2 is subset of testSet");
|
||||
|
||||
o9 = @"Hello";
|
||||
o10 = @"World";
|
||||
o11 = @"Ready";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue