Oolite 1.91.0.7645-241119-222d325
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#if OOLITE_FAST_ENUMERATION
35<NSFastEnumeration>
36#endif
37{
38@private
39 NSUInteger _count, _capacity;
40 unsigned long _updateCount;
43 NSString *_name;
44
45 struct JSObject *_jsSelf;
46}
47
48- (id) init;
49- (id) initWithName:(NSString *)name;
50+ (instancetype) groupWithName:(NSString *)name;
51+ (instancetype) groupWithName:(NSString *)name leader:(ShipEntity *)leader;
52
53- (NSString *) name;
54- (void) setName:(NSString *)name;
55
56- (ShipEntity *) leader;
57- (void) setLeader:(ShipEntity *)leader;
58
59- (NSEnumerator *) objectEnumerator;
60- (NSEnumerator *) mutationSafeEnumerator; // Enumerate over contents at time this is called, even if actual group is mutated.
61
62- (NSSet *) members;
63- (NSArray *) memberArray; // arbitrary order
64- (NSSet *) membersExcludingLeader;
65- (NSArray *) memberArrayExcludingLeader; // arbitrary order
66
67- (BOOL) containsShip:(ShipEntity *)ship;
68- (BOOL) addShip:(ShipEntity *)ship;
69- (BOOL) removeShip:(ShipEntity *)ship;
70
71- (NSUInteger) count; // NOTE: this is O(n).
72- (BOOL) isEmpty;
73
74@end
unsigned count
NSString * _name
Definition OOShipGroup.h:43
OOWeakReference ** _members
Definition OOShipGroup.h:41
< NSFastEnumeration > unsigned long _updateCount
Definition OOShipGroup.h:40
struct JSObject * _jsSelf
Definition OOShipGroup.h:45
OOWeakReference * _leader
Definition OOShipGroup.h:42