Some set tidyups

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@8274 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-12-07 22:57:56 +00:00
parent 4d3ec2af14
commit edc67ffd44
8 changed files with 353 additions and 380 deletions

View file

@ -1,3 +1,11 @@
2000-12-07 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSGSet.m: renamed to GSSet.m for consistency, tidied.
* Source/NSGCountedSet.m: renamed to GSCountedSet.m for consistency.
* Headers/Foundation/NSGSet.h: removed - obsolete.
* Source/NSSet.m: Updated and tidied. Fixed coding class for
mutable sets.
2000-12-05 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSURLHandle.m: minor mods to background loading.

View file

@ -1,39 +0,0 @@
/* Interface to concrete implementation of NSSet based on GNU Array
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
Date: April 1995
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef __NSGSet_h_GNUSTEP_BASE_INCLUDE
#define __NSGSet_h_GNUSTEP_BASE_INCLUDE
#include <Foundation/NSSet.h>
@interface NSGSet : NSSet
@end
@interface NSGMutableSet : NSMutableSet
@end
@interface NSGCountedSet : NSCountedSet
@end
#endif /* __NSGSet_h_GNUSTEP_BASE_INCLUDE */

View file

@ -144,8 +144,10 @@ preface.h
# GNUStep source files
BASE_MFILES = \
GSCountedSet.m \
GSHTTPURLHandle.m \
GSMime.m \
GSSet.m \
GSString.m \
NSAttributedString.m \
NSArchiver.m \
@ -181,9 +183,7 @@ NSFormatter.m \
NSGeometry.m \
NSGArray.m \
NSGAttributedString.m \
NSGCountedSet.m \
NSGDictionary.m \
NSGSet.m \
NSHashTable.m \
NSHost.m \
NSInvocation.m \
@ -289,7 +289,6 @@ NSFormatter.h \
NSGeometry.h \
NSGArray.h \
NSGAttributedString.h \
NSGSet.h \
NSHashTable.h \
NSHost.h \
NSInvocation.h \

View file

@ -1,5 +1,5 @@
/* Concrete implementation of NSSet based on GNU Set class
Copyright (C) 1998 Free Software Foundation, Inc.
/* Concrete implementation of NSCountedSet based on GNU Set class
Copyright (C) 1998,2000 Free Software Foundation, Inc.
Written by: Richard frith-Macdonald <richard@brainstorm.co.uk>
Created: October 1998
@ -42,28 +42,34 @@
@class NSSetNonCore;
@class NSMutableSetNonCore;
@interface NSGCountedSet : NSCountedSet
@interface GSCountedSet : NSCountedSet
{
@public
GSIMapTable_t map;
}
@end
@interface NSGCountedSetEnumerator : NSEnumerator
@interface GSCountedSetEnumerator : NSEnumerator
{
NSGCountedSet *set;
GSCountedSet *set;
GSIMapNode node;
}
@end
@implementation NSGCountedSetEnumerator
@implementation GSCountedSetEnumerator
- (void) dealloc
{
RELEASE(set);
[super dealloc];
}
- (id) initWithSet: (NSSet*)d
{
self = [super init];
if (self)
{
set = RETAIN((NSGCountedSet*)d);
set = RETAIN((GSCountedSet*)d);
node = set->map.firstNode;
}
return self;
@ -81,113 +87,20 @@
return old->key.obj;
}
- (void) dealloc
{
RELEASE(set);
[super dealloc];
}
@end
@implementation NSGCountedSet
@implementation GSCountedSet
+ (void) initialize
{
if (self == [NSGCountedSet class])
if (self == [GSCountedSet class])
{
class_add_behavior(self, [NSSetNonCore class]);
class_add_behavior(self, [NSMutableSetNonCore class]);
}
}
- (void) dealloc
{
GSIMapEmptyMap(&map);
[super dealloc];
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
unsigned count = map.nodeCount;
GSIMapNode node = map.firstNode;
SEL sel1 = @selector(encodeObject:);
IMP imp1 = [aCoder methodForSelector: sel1];
SEL sel2 = @selector(encodeValueOfObjCType:at:);
IMP imp2 = [aCoder methodForSelector: sel2];
const char *type = @encode(unsigned);
(*imp2)(aCoder, sel2, type, &count);
while (node != 0)
{
(*imp1)(aCoder, sel1, node->key.obj);
(*imp2)(aCoder, sel2, type, &node->value.uint);
node = node->nextInMap;
}
}
- (id) initWithCoder: (NSCoder*)aCoder
{
unsigned count;
id value;
unsigned valcnt;
SEL sel = @selector(decodeValueOfObjCType:at:);
IMP imp = [aCoder methodForSelector: sel];
const char *utype = @encode(unsigned);
const char *otype = @encode(id);
(*imp)(aCoder, sel, utype, &count);
GSIMapInitWithZoneAndCapacity(&map, [self zone], count);
while (count-- > 0)
{
(*imp)(aCoder, sel, otype, &value);
(*imp)(aCoder, sel, utype, &valcnt);
GSIMapAddPairNoRetain(&map, (GSIMapKey)value, (GSIMapVal)valcnt);
}
return self;
}
/* Designated initialiser */
- (id) initWithCapacity: (unsigned)cap
{
GSIMapInitWithZoneAndCapacity(&map, [self zone], cap);
return self;
}
- (id) initWithObjects: (id*)objs count: (unsigned)c
{
int i;
if ([self initWithCapacity: c] == nil)
{
return nil;
}
for (i = 0; i < c; i++)
{
GSIMapNode node;
if (objs[i] == nil)
{
IF_NO_GC(AUTORELEASE(self));
[NSException raise: NSInvalidArgumentException
format: @"Tried to init counted set with nil value"];
}
node = GSIMapNodeForKey(&map, (GSIMapKey)objs[i]);
if (node == 0)
{
GSIMapAddPair(&map,(GSIMapKey)objs[i],(GSIMapVal)(unsigned)1);
}
else
{
node->value.uint++;
}
}
return self;
}
- (void) addObject: (NSObject*)anObject
{
GSIMapNode node;
@ -228,18 +141,105 @@
return 0;
}
- (void) dealloc
{
GSIMapEmptyMap(&map);
[super dealloc];
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
unsigned count = map.nodeCount;
GSIMapNode node = map.firstNode;
SEL sel1 = @selector(encodeObject:);
IMP imp1 = [aCoder methodForSelector: sel1];
SEL sel2 = @selector(encodeValueOfObjCType:at:);
IMP imp2 = [aCoder methodForSelector: sel2];
const char *type = @encode(unsigned);
(*imp2)(aCoder, sel2, type, &count);
while (node != 0)
{
(*imp1)(aCoder, sel1, node->key.obj);
(*imp2)(aCoder, sel2, type, &node->value.uint);
node = node->nextInMap;
}
}
- (unsigned) hash
{
return map.nodeCount;
}
/* Designated initialiser */
- (id) initWithCapacity: (unsigned)cap
{
GSIMapInitWithZoneAndCapacity(&map, [self zone], cap);
return self;
}
- (id) initWithCoder: (NSCoder*)aCoder
{
unsigned count;
id value;
unsigned valcnt;
SEL sel = @selector(decodeValueOfObjCType:at:);
IMP imp = [aCoder methodForSelector: sel];
const char *utype = @encode(unsigned);
const char *otype = @encode(id);
(*imp)(aCoder, sel, utype, &count);
GSIMapInitWithZoneAndCapacity(&map, [self zone], count);
while (count-- > 0)
{
(*imp)(aCoder, sel, otype, &value);
(*imp)(aCoder, sel, utype, &valcnt);
GSIMapAddPairNoRetain(&map, (GSIMapKey)value, (GSIMapVal)valcnt);
}
return self;
}
- (id) initWithObjects: (id*)objs count: (unsigned)c
{
int i;
if ([self initWithCapacity: c] == nil)
{
return nil;
}
for (i = 0; i < c; i++)
{
GSIMapNode node;
if (objs[i] == nil)
{
IF_NO_GC(AUTORELEASE(self));
[NSException raise: NSInvalidArgumentException
format: @"Tried to init counted set with nil value"];
}
node = GSIMapNodeForKey(&map, (GSIMapKey)objs[i]);
if (node == 0)
{
GSIMapAddPair(&map,(GSIMapKey)objs[i],(GSIMapVal)(unsigned)1);
}
else
{
node->value.uint++;
}
}
return self;
}
- (id) member: (id)anObject
{
if (anObject)
if (anObject != nil)
{
GSIMapNode node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node)
if (node != 0)
{
return node->key.obj;
}
@ -249,7 +249,7 @@
- (NSEnumerator*) objectEnumerator
{
return AUTORELEASE([[NSGCountedSetEnumerator allocWithZone:
return AUTORELEASE([[GSCountedSetEnumerator allocWithZone:
NSDefaultMallocZone()] initWithSet: self]);
}
@ -276,6 +276,11 @@
}
}
- (void) removeAllObjects
{
GSIMapCleanMap(&map);
}
- (void) removeObject: (NSObject*)anObject
{
GSIMapBucket bucket;
@ -302,11 +307,6 @@
}
}
- (void) removeAllObjects
{
GSIMapCleanMap(&map);
}
- (id) unique: (id)anObject
{
GSIMapNode node;

View file

@ -1,9 +1,9 @@
/* Concrete implementation of NSSet based on GNU Set class
Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1998, 2000 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
Created: September 1995
Rewrite by: Richard frith-Macdonald <richard@brainstorm.co.uk>
Rewrite by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
This file is part of the GNUstep Base Library.
@ -42,35 +42,35 @@
@class NSSetNonCore;
@class NSMutableSetNonCore;
@interface NSGSet : NSSet
@interface GSSet : NSSet
{
@public
GSIMapTable_t map;
}
@end
@interface NSGMutableSet : NSMutableSet
@interface GSMutableSet : NSMutableSet
{
@public
GSIMapTable_t map;
}
@end
@interface NSGSetEnumerator : NSEnumerator
@interface GSSetEnumerator : NSEnumerator
{
NSGSet *set;
GSSet *set;
GSIMapNode node;
}
@end
@implementation NSGSetEnumerator
@implementation GSSetEnumerator
- (id) initWithSet: (NSSet*)d
{
self = [super init];
if (self != nil)
{
set = (NSGSet*)RETAIN(d);
set = (GSSet*)RETAIN(d);
node = set->map.firstNode;
}
return self;
@ -97,7 +97,7 @@
@end
@implementation NSGSet
@implementation GSSet
static Class arrayClass;
static Class setClass;
@ -105,74 +105,15 @@ static Class mutableSetClass;
+ (void) initialize
{
if (self == [NSGSet class])
if (self == [GSSet class])
{
class_add_behavior(self, [NSSetNonCore class]);
arrayClass = [NSArray class];
setClass = [NSGSet class];
mutableSetClass = [NSGMutableSet class];
setClass = [GSSet class];
mutableSetClass = [GSMutableSet class];
}
}
- (unsigned) count
{
return map.nodeCount;
}
- (void) dealloc
{
GSIMapEmptyMap(&map);
[super dealloc];
}
/* Designated initialiser */
- (id) initWithObjects: (id*)objs count: (unsigned)c
{
int i;
GSIMapInitWithZoneAndCapacity(&map, [self zone], c);
for (i = 0; i < c; i++)
{
GSIMapNode node;
if (objs[i] == nil)
{
IF_NO_GC(AUTORELEASE(self));
[NSException raise: NSInvalidArgumentException
format: @"Tried to init set with nil value"];
}
node = GSIMapNodeForKey(&map, (GSIMapKey)objs[i]);
if (node == 0)
{
GSIMapAddKey(&map, (GSIMapKey)objs[i]);
}
}
return self;
}
- (id) member: (id)anObject
{
if (anObject)
{
GSIMapNode node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node)
{
return node->key.obj;
}
}
return nil;
}
- (NSEnumerator*) objectEnumerator
{
return AUTORELEASE([[NSGSetEnumerator alloc] initWithSet: self]);
}
@end
@implementation NSGSet (NonCore)
- (NSArray*) allObjects
{
id objs[map.nodeCount];
@ -191,9 +132,24 @@ static Class mutableSetClass;
- (id) anyObject
{
if (map.nodeCount > 0)
return map.firstNode->key.obj;
{
return map.firstNode->key.obj;
}
else
return nil;
{
return nil;
}
}
- (unsigned) count
{
return map.nodeCount;
}
- (void) dealloc
{
GSIMapEmptyMap(&map);
[super dealloc];
}
- (void) encodeWithCoder: (NSCoder*)aCoder
@ -236,6 +192,31 @@ static Class mutableSetClass;
return self;
}
/* Designated initialiser */
- (id) initWithObjects: (id*)objs count: (unsigned)c
{
unsigned i;
GSIMapInitWithZoneAndCapacity(&map, [self zone], c);
for (i = 0; i < c; i++)
{
GSIMapNode node;
if (objs[i] == nil)
{
IF_NO_GC(AUTORELEASE(self));
[NSException raise: NSInvalidArgumentException
format: @"Tried to init set with nil value"];
}
node = GSIMapNodeForKey(&map, (GSIMapKey)objs[i]);
if (node == 0)
{
GSIMapAddKey(&map, (GSIMapKey)objs[i]);
}
}
return self;
}
- (BOOL) intersectsSet: (NSSet*) otherSet
{
Class c;
@ -244,15 +225,19 @@ static Class mutableSetClass;
* If this set is empty, or the other is nil, this method should return NO.
*/
if (map.nodeCount == 0)
return NO;
{
return NO;
}
if (otherSet == nil)
return NO;
{
return NO;
}
// Loop for all members in otherSet
c = GSObjCClass(otherSet);
if (c == setClass || c == mutableSetClass)
{
GSIMapNode node = ((NSGSet*)otherSet)->map.firstNode;
GSIMapNode node = ((GSSet*)otherSet)->map.firstNode;
while (node != 0)
{
@ -286,7 +271,9 @@ static Class mutableSetClass;
// -1. members of this set(self) <= that of otherSet
if (map.nodeCount > [otherSet count])
return NO;
{
return NO;
}
// 0. Loop for all members in this set(self).
while (node != 0)
@ -323,7 +310,7 @@ static Class mutableSetClass;
if (c == setClass || c == mutableSetClass)
{
if (map.nodeCount != ((NSGSet*)other)->map.nodeCount)
if (map.nodeCount != ((GSSet*)other)->map.nodeCount)
{
return NO;
}
@ -333,7 +320,7 @@ static Class mutableSetClass;
while (node != 0)
{
if (GSIMapNodeForKey(&(((NSGSet*)other)->map), node->key)
if (GSIMapNodeForKey(&(((GSSet*)other)->map), node->key)
== 0)
{
return NO;
@ -410,16 +397,77 @@ static Class mutableSetClass;
}
}
- (id) member: (id)anObject
{
if (anObject != nil)
{
GSIMapNode node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node != 0)
{
return node->key.obj;
}
}
return nil;
}
- (NSEnumerator*) objectEnumerator
{
return AUTORELEASE([[GSSetEnumerator alloc] initWithSet: self]);
}
@end
@implementation NSGMutableSet
@implementation GSMutableSet
+ (void) initialize
{
if (self == [NSGMutableSet class])
if (self == [GSMutableSet class])
{
class_add_behavior(self, [NSMutableSetNonCore class]);
class_add_behavior(self, [NSGSet class]);
class_add_behavior(self, [GSSet class]);
}
}
- (void) addObject: (NSObject*)anObject
{
GSIMapNode node;
if (anObject == nil)
{
[NSException raise: NSInvalidArgumentException
format: @"Tried to add nil to set"];
}
node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node == 0)
{
GSIMapAddKey(&map, (GSIMapKey)anObject);
}
}
- (void) addObjectsFromArray: (NSArray*)array
{
unsigned count = [array count];
while (count-- > 0)
{
id anObject = [array objectAtIndex: count];
if (anObject == nil)
{
[NSException raise: NSInvalidArgumentException
format: @"Tried to add nil to set"];
}
else
{
GSIMapNode node;
node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node == 0)
{
GSIMapAddKey(&map, (GSIMapKey)anObject);
}
}
}
}
@ -458,92 +506,6 @@ static Class mutableSetClass;
return self;
}
- (void) addObject: (NSObject*)anObject
{
GSIMapNode node;
if (anObject == nil)
{
[NSException raise: NSInvalidArgumentException
format: @"Tried to add nil to set"];
}
node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node == 0)
{
GSIMapAddKey(&map, (GSIMapKey)anObject);
}
}
- (void) removeObject: (NSObject *)anObject
{
if (anObject == nil)
{
NSWarnMLog(@"attempt to remove nil object", 0);
return;
}
GSIMapRemoveKey(&map, (GSIMapKey)anObject);
}
- (void) removeAllObjects
{
GSIMapCleanMap(&map);
}
@end
@implementation NSGMutableSet (NonCore)
- (void) addObjectsFromArray: (NSArray*)array
{
unsigned count = [array count];
while (count--)
{
id anObject = [array objectAtIndex: count];
if (anObject == nil)
{
[NSException raise: NSInvalidArgumentException
format: @"Tried to add nil to set"];
}
else
{
GSIMapNode node;
node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node == 0)
{
GSIMapAddKey(&map, (GSIMapKey)anObject);
}
}
}
}
- (void) unionSet: (NSSet*) other
{
if (other != self)
{
NSEnumerator *e = [other objectEnumerator];
id anObject;
while ((anObject = [e nextObject]) != nil)
{
GSIMapNode node;
if (anObject == nil)
{
[NSException raise: NSInvalidArgumentException
format: @"Tried to add nil to set"];
}
node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node == 0)
{
GSIMapAddKey(&map, (GSIMapKey)anObject);
}
}
}
}
- (void) intersectSet: (NSSet*) other
{
if (other != self)
@ -581,4 +543,45 @@ static Class mutableSetClass;
}
}
- (void) removeAllObjects
{
GSIMapCleanMap(&map);
}
- (void) removeObject: (NSObject *)anObject
{
if (anObject == nil)
{
NSWarnMLog(@"attempt to remove nil object", 0);
return;
}
GSIMapRemoveKey(&map, (GSIMapKey)anObject);
}
- (void) unionSet: (NSSet*) other
{
if (other != self)
{
NSEnumerator *e = [other objectEnumerator];
id anObject;
while ((anObject = [e nextObject]) != nil)
{
GSIMapNode node;
if (anObject == nil)
{
[NSException raise: NSInvalidArgumentException
format: @"Tried to add nil to set"];
}
node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node == 0)
{
GSIMapAddKey(&map, (GSIMapKey)anObject);
}
}
}
}
@end

View file

@ -224,10 +224,10 @@ $(GNUSTEP_OBJ_DIR)/NSUnarchiver.o \
#
# Files that include GSIMap.h will need a rebuild if it is changed.
#
$(GNUSTEP_OBJ_DIR)/GSCountedSet.o \
$(GNUSTEP_OBJ_DIR)/GSSet.o \
$(GNUSTEP_OBJ_DIR)/NSArchiver.o \
$(GNUSTEP_OBJ_DIR)/NSGCountedSet.o \
$(GNUSTEP_OBJ_DIR)/NSGDictionary.o \
$(GNUSTEP_OBJ_DIR)/NSGSet.o \
$(GNUSTEP_OBJ_DIR)/NSNotificationCenter.o \
$(GNUSTEP_OBJ_DIR)/NSSerializer.o \
: $(HEADER_DIR)/GSIMap.h $(HEADER_DIR)/GSUnion.h

View file

@ -24,7 +24,6 @@
#include <config.h>
#include <base/behavior.h>
#include <Foundation/NSSet.h>
#include <Foundation/NSGSet.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSUtilities.h>
@ -36,6 +35,7 @@
@class NSSetNonCore;
@class NSMutableSetNonCore;
@class GSCountedSet;
/*
* Class variables for uniquing objects;
@ -61,7 +61,7 @@ static Class NSCountedSet_concrete_class;
if (self == [NSCountedSet class])
{
NSCountedSet_abstract_class = self;
NSCountedSet_concrete_class = [NSGCountedSet class];
NSCountedSet_concrete_class = [GSCountedSet class];
behavior_class_add_class(self, [NSMutableSetNonCore class]);
behavior_class_add_class(self, [NSSetNonCore class]);
if ([NSThread isMultiThreaded])

View file

@ -24,7 +24,6 @@
#include <config.h>
#include <base/behavior.h>
#include <Foundation/NSSet.h>
#include <Foundation/NSGSet.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSUtilities.h>
@ -32,6 +31,9 @@
#include <Foundation/NSException.h>
#include <Foundation/NSObjCRuntime.h>
@class GSSet;
@class GSMutableSet;
@interface NSSetNonCore : NSSet
@end
@interface NSMutableSetNonCore: NSMutableSet
@ -44,14 +46,26 @@ static Class NSMutableSet_abstract_class;
static Class NSSet_concrete_class;
static Class NSMutableSet_concrete_class;
+ (id) allocWithZone: (NSZone*)z
{
if (self == NSSet_abstract_class)
{
return NSAllocateObject(NSSet_concrete_class, 0, z);
}
else
{
return NSAllocateObject(self, 0, z);
}
}
+ (void) initialize
{
if (self == [NSSet class])
{
NSSet_abstract_class = [NSSet class];
NSMutableSet_abstract_class = [NSMutableSet class];
NSSet_concrete_class = [NSGSet class];
NSMutableSet_concrete_class = [NSGMutableSet class];
NSSet_concrete_class = [GSSet class];
NSMutableSet_concrete_class = [GSMutableSet class];
behavior_class_add_class(self, [NSSetNonCore class]);
}
}
@ -61,13 +75,6 @@ static Class NSMutableSet_concrete_class;
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()] init]);
}
+ (id) setWithObjects: (id*)objects
count: (unsigned)count
{
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
initWithObjects: objects count: count]);
}
+ (id) setWithArray: (NSArray*)objects
{
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
@ -80,6 +87,13 @@ static Class NSMutableSet_concrete_class;
initWithObjects: &anObject count: 1]);
}
+ (id) setWithObjects: (id*)objects
count: (unsigned)count
{
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
initWithObjects: objects count: count]);
}
+ (id) setWithObjects: firstObject, ...
{
id set;
@ -97,26 +111,35 @@ static Class NSMutableSet_concrete_class;
initWithSet: aSet]);
}
+ (id) allocWithZone: (NSZone*)z
- (Class) classForCoder
{
if (self == NSSet_abstract_class)
{
return NSAllocateObject(NSSet_concrete_class, 0, z);
}
else
{
return NSAllocateObject(self, 0, z);
}
return NSSet_abstract_class;
}
/* This is the designated initializer */
- (id) initWithObjects: (id*)objects
count: (unsigned)count
- (id) copyWithZone: (NSZone*)z
{
return RETAIN(self);
}
- (unsigned) count
{
[self subclassResponsibility: _cmd];
return 0;
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
unsigned count = [self count];
NSEnumerator *e = [self objectEnumerator];
id o;
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &count];
while ((o = [e nextObject]) != nil)
{
[aCoder encodeValueOfObjCType: @encode(id) at: &o];
}
}
- (id) initWithCoder: (NSCoder*)aCoder
{
unsigned count;
@ -148,51 +171,30 @@ static Class NSMutableSet_concrete_class;
}
}
- (Class) classForCoder
{
return NSSet_abstract_class;
}
- (unsigned) count
/* This is the designated initializer */
- (id) initWithObjects: (id*)objects
count: (unsigned)count
{
[self subclassResponsibility: _cmd];
return 0;
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
unsigned count = [self count];
NSEnumerator *e = [self objectEnumerator];
id o;
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &count];
while ((o = [e nextObject]) != nil)
{
[aCoder encodeValueOfObjCType: @encode(id) at: &o];
}
}
- (id) member: (id)anObject
{
return [self subclassResponsibility: _cmd];
return 0;
}
- (NSEnumerator*) objectEnumerator
{
return [self subclassResponsibility: _cmd];
}
- (id) copyWithZone: (NSZone*)z
{
return RETAIN(self);
}
- (id) mutableCopyWithZone: (NSZone*)z
{
return [[NSMutableSet_concrete_class allocWithZone: z] initWithSet: self];
}
- (NSEnumerator*) objectEnumerator
{
return [self subclassResponsibility: _cmd];
}
@end
@implementation NSSetNonCore
@ -331,11 +333,6 @@ static Class NSMutableSet_concrete_class;
}
}
- (Class) classForCoder
{
return NSSet_abstract_class;
}
- (BOOL) containsObject: (id)anObject
{
return (([self member: anObject]) ? YES : NO);
@ -488,6 +485,11 @@ static Class NSMutableSet_concrete_class;
}
}
- (Class) classForCoder
{
return NSMutableSet_concrete_class;
}
- (id) copyWithZone: (NSZone*)z
{
return [[NSSet_concrete_class allocWithZone: z] initWithSet: self];