Oolite
Loading...
Searching...
No Matches
OOExcludeObjectEnumerator.m
Go to the documentation of this file.
1
/*
2
3
OOExcludeObjectEnumerator.m
4
5
6
Oolite
7
Copyright (C) 2004-2013 Giles C Williams and contributors
8
9
This program is free software; you can redistribute it and/or
10
modify it under the terms of the GNU General Public License
11
as published by the Free Software Foundation; either version 2
12
of the License, or (at your option) any later version.
13
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
MA 02110-1301, USA.
23
24
*/
25
26
#import "
OOExcludeObjectEnumerator.h
"
27
28
@implementation
OOExcludeObjectEnumerator
29
30
- (id)initWithEnumerator:(NSEnumerator*)enumerator
31
excludingObject:(
id
)object
32
{
33
if
((
self
= [super init])) {
34
_enumerator
= [
enumerator
retain];
35
_excludeObject
= [
object
retain];
36
}
37
38
return
self
;
39
}
40
41
- (void)
dealloc
42
{
43
[
_enumerator
release];
44
[_excludeObject release];
45
46
[
super
dealloc];
47
}
48
49
+ (id)enumeratorWithEnumerator:(NSEnumerator*)enumerator
50
excludingObject:(
id
)object
51
{
52
if
(
object
==
nil
)
53
return
enumerator;
54
if
(enumerator ==
nil
)
55
return
nil
;
56
57
return
[[[
self
alloc] initWithEnumerator:enumerator excludingObject:object] autorelease];
58
}
59
60
- (id)
nextObject
61
{
62
id
result =
nil
;
63
do
{
64
result = [
_enumerator
nextObject];
65
}
while
(result ==
_excludeObject
&& result !=
nil
);
66
67
return
result;
68
}
69
70
@end
71
72
@implementation
NSEnumerator (OOExcludingObject)
73
74
- (id)ooExcludingObject:(
id
)object
75
{
76
return
[
OOExcludeObjectEnumerator
enumeratorWithEnumerator
:
self
excludingObject
:object];
77
}
78
79
@end
OOExcludeObjectEnumerator.h
nil
return nil
Definition
OOProbabilitySet.m:393
NSEnumerator
OOExcludeObjectEnumerator
Definition
OOExcludeObjectEnumerator.h:30
OOExcludeObjectEnumerator::_enumerator
NSEnumerator * _enumerator
Definition
OOExcludeObjectEnumerator.h:32
-[OOExcludeObjectEnumerator dealloc]
void dealloc()
Definition
OOExcludeObjectEnumerator.m:41
+[OOExcludeObjectEnumerator enumeratorWithEnumerator:excludingObject:]
id enumeratorWithEnumerator:excludingObject:(NSEnumerator *enumerator,[excludingObject] id object)
Definition
OOExcludeObjectEnumerator.m:49
OOExcludeObjectEnumerator::_excludeObject
id _excludeObject
Definition
OOExcludeObjectEnumerator.h:33
-[OOExcludeObjectEnumerator nextObject]
id nextObject()
Definition
OOExcludeObjectEnumerator.m:60
src
Core
OOExcludeObjectEnumerator.m
Generated by
1.15.0