mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-11 16:50:42 +00:00
Tidied
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16380 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
af61167161
commit
0f05f2246c
2 changed files with 7 additions and 60 deletions
|
@ -55,8 +55,6 @@
|
||||||
- (id) initWithObjects: (id)firstObject, ...;
|
- (id) initWithObjects: (id)firstObject, ...;
|
||||||
- (id) initWithObjects: (id*)objects
|
- (id) initWithObjects: (id*)objects
|
||||||
count: (unsigned)count;
|
count: (unsigned)count;
|
||||||
- (id) initWithObjects: firstObject
|
|
||||||
rest: (va_list)ap;
|
|
||||||
- (id) initWithSet: (NSSet*)other;
|
- (id) initWithSet: (NSSet*)other;
|
||||||
- (id) initWithSet: (NSSet*)other copyItems: (BOOL)flag;
|
- (id) initWithSet: (NSSet*)other copyItems: (BOOL)flag;
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSObjCRuntime.h>
|
#include <Foundation/NSObjCRuntime.h>
|
||||||
#include <Foundation/NSDebug.h>
|
#include <Foundation/NSDebug.h>
|
||||||
|
#include "gnustep/base/GSCategories.h"
|
||||||
|
|
||||||
@class GSSet;
|
@class GSSet;
|
||||||
@class GSMutableSet;
|
@class GSMutableSet;
|
||||||
|
@ -94,11 +95,10 @@ static Class NSMutableSet_concrete_class;
|
||||||
+ (id) setWithObjects: firstObject, ...
|
+ (id) setWithObjects: firstObject, ...
|
||||||
{
|
{
|
||||||
id set;
|
id set;
|
||||||
va_list ap;
|
|
||||||
va_start(ap, firstObject);
|
GS_USEIDLIST(firstObject,
|
||||||
set = [[self allocWithZone: NSDefaultMallocZone()]
|
set = [[self allocWithZone: NSDefaultMallocZone()]
|
||||||
initWithObjects: firstObject rest: ap];
|
initWithObjects: __objects count: __count]);
|
||||||
va_end(ap);
|
|
||||||
return AUTORELEASE(set);
|
return AUTORELEASE(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,61 +213,10 @@ static Class NSMutableSet_concrete_class;
|
||||||
return [self subclassResponsibility: _cmd];
|
return [self subclassResponsibility: _cmd];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Same as NSArray */
|
|
||||||
- (id) initWithObjects: firstObject rest: (va_list)ap
|
|
||||||
{
|
|
||||||
register unsigned i;
|
|
||||||
register unsigned curSize;
|
|
||||||
auto unsigned prevSize;
|
|
||||||
auto unsigned newSize;
|
|
||||||
auto id *objsArray;
|
|
||||||
auto id tmpId;
|
|
||||||
|
|
||||||
/* Do initial allocation. */
|
|
||||||
prevSize = 3;
|
|
||||||
curSize = 5;
|
|
||||||
objsArray = (id*)NSZoneMalloc(NSDefaultMallocZone(), sizeof(id) * curSize);
|
|
||||||
tmpId = firstObject;
|
|
||||||
|
|
||||||
/* Loop through adding objects to array until a nil is
|
|
||||||
* found.
|
|
||||||
*/
|
|
||||||
for (i = 0; tmpId != nil; i++)
|
|
||||||
{
|
|
||||||
/* Put id into array. */
|
|
||||||
objsArray[i] = tmpId;
|
|
||||||
|
|
||||||
/* If the index equals the current size, increase size. */
|
|
||||||
if (i == curSize - 1)
|
|
||||||
{
|
|
||||||
/* Fibonacci series. Supposedly, for this application,
|
|
||||||
* the fibonacci series will be more memory efficient.
|
|
||||||
*/
|
|
||||||
newSize = prevSize + curSize;
|
|
||||||
prevSize = curSize;
|
|
||||||
curSize = newSize;
|
|
||||||
|
|
||||||
/* Reallocate object array. */
|
|
||||||
objsArray = (id*)NSZoneRealloc(NSDefaultMallocZone(), objsArray,
|
|
||||||
sizeof(id) * curSize);
|
|
||||||
}
|
|
||||||
tmpId = va_arg(ap, id);
|
|
||||||
}
|
|
||||||
va_end( ap );
|
|
||||||
|
|
||||||
/* Put object ids into NSSet. */
|
|
||||||
self = [self initWithObjects: objsArray count: i];
|
|
||||||
NSZoneFree(NSDefaultMallocZone(), objsArray);
|
|
||||||
return( self );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Same as NSArray */
|
|
||||||
- (id) initWithObjects: firstObject, ...
|
- (id) initWithObjects: firstObject, ...
|
||||||
{
|
{
|
||||||
va_list ap;
|
GS_USEIDLIST(firstObject,
|
||||||
va_start(ap, firstObject);
|
self = [self initWithObjects: __objects count: __count]);
|
||||||
self = [self initWithObjects: firstObject rest: ap];
|
|
||||||
va_end(ap);
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue