43 return [_CPPlaceholderSet alloc];
53 return [[
self alloc] init];
62 return [[
self alloc] initWithArray:anArray];
69 + (id)setWithObject:(
id)anObject
71 return [[
self alloc] initWithObjects:anObject];
79 + (id)setWithObjects:(
id)objects count:(CPUInteger)count
81 return [[
self alloc] initWithObjects:objects count:count];
89 + (id)setWithObjects:(
id)anObject, ...
91 var argumentsArray = Array.prototype.slice.apply(arguments);
93 argumentsArray[0] = [
self alloc];
94 argumentsArray[1] =
@selector(initWithObjects:);
96 return objj_msgSend.apply(
this, argumentsArray);
112 - (id)setByAddingObject:(
id)anObject
121 - (id)setByAddingObjectsFromSet:(
CPSet)aSet
130 - (id)setByAddingObjectsFromArray:(
CPArray)anArray
157 - (id)initWithObjects:(
id)anObject, ...
160 count = arguments.length;
162 for (; index < count; ++index)
163 if (arguments[index] === nil)
174 - (id)initWithObjects:(
CPArray)objects count:(CPUInteger)aCount
176 if (
self === _CPSharedPlaceholderSet)
177 return [[_CPConcreteMutableSet alloc] initWithObjects:objects count:aCount];
196 - (id)initWithSet:(
CPSet)aSet copyItems:(BOOL)shouldCopyItems
209 _CPRaiseInvalidAbstractInvocation(
self, _cmd);
221 while ((
object = [objectEnumerator nextObject]) !== nil)
222 objects.push(
object);
239 - (BOOL)containsObject:(
id)anObject
241 return [
self member:anObject] !== nil;
254 while ((
object = [objectEnumerator nextObject]) !== nil)
255 if ([aPredicate evaluateWithObject:
object])
256 objects.push(
object);
258 return [[[
self class] alloc] initWithArray:objects];
265 - (void)makeObjectsPerformSelector:(
SEL)aSelector
275 - (void)makeObjectsPerformSelector:(
SEL)aSelector withObject:(
id)anObject
285 - (void)makeObjectsPerformSelector:(
SEL)aSelector withObjects:(
CPArray)objects
289 argumentsArray = [nil, aSelector].concat(objects || []);
291 while ((
object = [objectEnumerator nextObject]) !== nil)
293 argumentsArray[0] = object;
294 objj_msgSend.apply(
this, argumentsArray);
302 - (id)member:(
id)anObject
304 _CPRaiseInvalidAbstractInvocation(
self, _cmd);
312 _CPRaiseInvalidAbstractInvocation(
self, _cmd);
319 - (void)enumerateObjectsUsingBlock:(Function)aFunction
324 while ((
object = [objectEnumerator nextObject]) !== nil)
325 if (aFunction(
object))
330 - (
CPSet)objectsPassingTest:(Function)aFunction
336 while ((
object = [objectEnumerator nextObject]) !== nil)
337 if (aFunction(
object))
338 objects.push(
object);
340 return [[[
self class] alloc] initWithArray:objects];
352 while ((
object = [objectEnumerator nextObject]) !== nil)
353 if (![aSet containsObject:
object])
367 return [
self count] > 0;
372 while ((
object = [objectEnumerator nextObject]) !== nil)
373 if ([aSet containsObject:
object])
405 return self === aSet ||
416 count = [objects
count];
418 for (; index < count; ++index)
420 var
object = objects[index];
422 string +=
"\t" + String(
object).split(
'\n').join(
"\n\t") +
"\n";
425 return string +
")}";
434 return [[
self class] setWithSet:self];
450 return [
self initWithArray:[aCoder decodeObjectForKey:CPSetObjectsKey]];
455 [aCoder encodeObject:[
self allObjects] forKey:CPSetObjectsKey];
464 if (aKey ===
"@count")
471 while ((
object = [objectEnumerator nextObject]) !== nil)
473 var value = [object valueForKey:aKey];
475 [valueSet addObject:value];
486 while ((
object = [objectEnumerator nextObject]) !== nil)
487 [object setValue:aValue forKey:aKey];
492 var _CPSharedPlaceholderSet = nil;
493 @implementation _CPPlaceholderSet :
CPSet
500 if (!_CPSharedPlaceholderSet)
501 _CPSharedPlaceholderSet = [
super alloc];
503 return _CPSharedPlaceholderSet;