Oolite 1.91.0.7668-250429-8542c40
All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
OOShipGroup(Private) Category Reference

Instance Methods

(BOOL) - resizeTo:
 
(void) - cleanUp
 
(NSUInteger) - updateCount
 

Detailed Description

Definition at line 65 of file OOShipGroup.m.

Method Documentation

◆ cleanUp

- (void) cleanUp

Extends class OOShipGroup.

Definition at line 443 of file OOShipGroup.m.

444{
445 NSUInteger newCapacity = _capacity;
446
447 if (_count >= kMaxFreeSpace)
448 {
449 if (_capacity > _count + kMaxFreeSpace)
450 {
451 newCapacity = _count + 1; // +1 keeps us at powers of two + multiples of kMaxFreespace.
452 }
453 }
454 else
455 {
456 if (_capacity > _count * 2)
457 {
458 newCapacity = OORoundUpToPowerOf2_NS(_count);
459 if (newCapacity < kMinSize) newCapacity = kMinSize;
460 }
461 }
462
463 if (newCapacity != _capacity) [self resizeTo:newCapacity];
464}
@ kMaxFreeSpace
Definition OOShipGroup.m:44
@ kMinSize
Definition OOShipGroup.m:43

References cleanUp, kMaxFreeSpace, kMinSize, and OOShipGroup::resizeTo:.

Referenced by cleanUp, OOShipGroup::countByEnumeratingWithState:objects:count:, OOShipGroup::removeShip:, and OOShipGroup::ShipGroupIterate.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resizeTo:

- (BOOL) resizeTo: (NSUInteger) newCapacity

Extends class OOShipGroup.

Definition at line 428 of file OOShipGroup.m.

428 :(NSUInteger)newCapacity
429{
430 OOWeakReference **temp = NULL;
431
432 if (newCapacity < _count) return NO;
433
434 temp = realloc(_members, newCapacity * sizeof *_members);
435 if (temp == NULL) return NO;
436
437 _members = temp;
438 _capacity = newCapacity;
439 return YES;
440}

Referenced by cleanUp.

+ Here is the caller graph for this function:

◆ updateCount

- (NSUInteger) updateCount

Extends class OOShipGroup.

Definition at line 467 of file OOShipGroup.m.

468{
469 return _updateCount;
470}

References updateCount.

Referenced by OOShipGroupEnumerator::initWithShipGroup:, and updateCount.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this category was generated from the following file: