Oolite
Loading...
Searching...
No Matches
OOShipGroup.h
Go to the documentation of this file.
1/*
2OOShipGroup.h
3
4A weak-referencing, mutable set of ships. Not thread safe.
5
6
7Oolite
8Copyright (C) 2004-2013 Giles C Williams and contributors
9
10This program is free software; you can redistribute it and/or
11modify it under the terms of the GNU General Public License
12as published by the Free Software Foundation; either version 2
13of the License, or (at your option) any later version.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23MA 02110-1301, USA.
24
25*/
26
27#import "OOCocoa.h"
28#import "OOWeakReference.h"
29
30@class ShipEntity;
31
32
34<NSFastEnumeration>
35{
36@private
37 NSUInteger _count, _capacity;
38 unsigned long _updateCount;
41 NSString *_name;
42
43 struct JSObject *_jsSelf;
44}
45
46- (id) init;
47- (id) initWithName:(NSString *)name;
48+ (instancetype) groupWithName:(NSString *)name;
49+ (instancetype) groupWithName:(NSString *)name leader:(ShipEntity *)leader;
50
51- (NSString *) name;
52- (void) setName:(NSString *)name;
53
54- (ShipEntity *) leader;
55- (void) setLeader:(ShipEntity *)leader;
56
57- (NSEnumerator *) objectEnumerator;
58- (NSEnumerator *) mutationSafeEnumerator; // Enumerate over contents at time this is called, even if actual group is mutated.
59
60- (NSSet *) members;
61- (NSArray *) memberArray; // arbitrary order
62- (NSSet *) membersExcludingLeader;
63- (NSArray *) memberArrayExcludingLeader; // arbitrary order
64
65- (BOOL) containsShip:(ShipEntity *)ship;
66- (BOOL) addShip:(ShipEntity *)ship;
67- (BOOL) removeShip:(ShipEntity *)ship;
68
69- (NSUInteger) count; // NOTE: this is O(n).
70- (BOOL) isEmpty;
71
72@end
unsigned count
NSString * _name
Definition OOShipGroup.h:41
OOWeakReference ** _members
Definition OOShipGroup.h:39
< NSFastEnumeration > unsigned long _updateCount
Definition OOShipGroup.h:38
struct JSObject * _jsSelf
Definition OOShipGroup.h:43
OOWeakReference * _leader
Definition OOShipGroup.h:40