56- (void)setPerformCleanup:(BOOL)flag;
60@interface OOShipGroup (Private)
62- (BOOL)resizeTo:(NSUInteger)newCapacity;
78- (id)initWithName:(NSString*)name
80 if ((
self = [super
init])) {
94+ (instancetype)groupWithName:(NSString*)name
96 return [[[
self alloc] initWithName:name] autorelease];
99+ (instancetype)groupWithName:(NSString*)name leader:(
ShipEntity*)leader
110 for (i = 0; i <
_count; i++) {
121 NSString* desc = [
NSString stringWithFormat:@"%zu ships", _count];
123 desc = [
NSString stringWithFormat:@"\"%@\", %@", [
self name], desc];
126 desc = [
NSString stringWithFormat:@"%@, leader: %@", desc, [[
self leader] shortDescription]];
136- (void)setName:(NSString*)name
142 _name = [name retain];
193 NSUInteger
count = 0;
194 NSArray* result =
nil;
199 objects = malloc(
sizeof *objects *
_count);
200 for (
id ship in
self) {
201 objects[count++] = ship;
204 result = [
NSArray arrayWithObjects:objects count:count];
213 NSUInteger
count = 0;
214 NSArray* result =
nil;
221 objects = malloc(
sizeof *objects *
_count);
222 for (
id ship in
self) {
224 objects[count++] = ship;
228 result = [
NSArray arrayWithObjects:objects count:count];
238 for (containedShip in
self) {
239 if ([ship isEqual:containedShip]) {
251 if ([
self containsShip:ship])
277 if (ship == [
self leader])
282 while ((containedShip = [shipEnum nextObject])) {
283 if ([ship isEqual:containedShip]) {
306 NSEnumerator* memberEnum =
nil;
307 NSUInteger result = 0;
311 while ([memberEnum nextObject] !=
nil)
328- (BOOL)resizeTo:(NSUInteger)newCapacity
332 if (newCapacity < _count)
335 temp = realloc(_members, newCapacity *
sizeof *_members);
340 _capacity = newCapacity;
346 NSUInteger newCapacity = _capacity;
350 newCapacity = _count + 1;
353 if (_capacity > _count * 2) {
354 newCapacity = OORoundUpToPowerOf2_NS(_count);
360 if (newCapacity != _capacity)
375 BOOL cleanupNeeded = NO;
378 [
NSException raise:NSGenericException format:@"Collection <OOShipGroup: %p> was mutated while being enumerated.", group];
404- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState*)state objects:(
id*)stackbuf count:(NSUInteger)len
406 NSUInteger srcIndex, dstIndex = 0;
408 BOOL cleanupNeeded = NO;
410 srcIndex = state->state;
411 while (srcIndex <
_count && dstIndex < len) {
425 state->state = srcIndex;
426 state->itemsPtr = stackbuf;
452 assert(group !=
nil);
454 if ((
self = [super init])) {
480- (void)setPerformCleanup:(BOOL)flag
static id ShipGroupIterate(OOShipGroupEnumerator *enumerator)
void setPerformCleanup:(BOOL flag)
void setName:(NSString *name)
BOOL addShip:(ShipEntity *ship)
OOWeakReference ** _members
id initWithName:(NSString *name)
void setLeader:(ShipEntity *leader)
NSEnumerator * mutationSafeEnumerator()
instancetype groupWithName:(NSString *name)
BOOL resizeTo:(NSUInteger newCapacity)
NSEnumerator * objectEnumerator()
BOOL suppressClangStuff()
NSString * descriptionComponents()
NSArray * memberArrayExcludingLeader()
unsigned long _updateCount
struct JSObject * _jsSelf
static id ShipGroupIterate(OOShipGroupEnumerator *enumerator)
NSSet * membersExcludingLeader()
OOWeakReference * _leader
id weakRefUnderlyingObject()
void setGroup:(OOShipGroup *group)
void setOwner:(Entity *who_owns_entity)