ObjFW  Diff

Differences From Artifact [0155b17e2f]:

To Artifact [654fa1e987]:


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#import "OFEnumerator.h"
#import "OFDictionary.h"
#import "OFExceptions.h"

/* Reference for static linking */
int _OFEnumerator_reference;

@implementation OFEnumerator
- init
{

	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithData: (struct of_dictionary_bucket*)data_
	  size: (size_t)size_
{
	size_t i;

	self = [super init];

	size = size_;
	data = [self allocMemoryForNItems: size
				 withSize: sizeof(struct of_dictionary_bucket)];

	for (i = 0; i < size; i++) {
		if (data_[i].key != nil) {
			data[i].key = [data_[i].key copy];
			data[i].object = [data_[i].object retain];
		} else
			data[i].key = nil;
	}

	return self;
}

- (void)dealloc
{
	size_t i;

	for (i = 0; i < size; i++) {
		if (data[i].key != nil) {
			[data[i].key release];
			[data[i].object release];
		}
	}

	[super dealloc];
}

- (of_enumerator_pair_t)nextKeyObjectPair
{
	of_enumerator_pair_t next;

	for (; pos < size && data[pos].key == nil; pos++);

	if (pos < size) {
		next.key = data[pos].key;
		next.object = data[pos].object;
		pos++;
	} else {
		next.key = nil;
		next.object = nil;
	}

	return next;
}

- reset
{
	pos = 0;

	return self;
}
@end

@implementation OFDictionary (OFEnumerator)
- (OFEnumerator*)enumerator
{
	return [[[OFEnumerator alloc] initWithData: data
					      size: size] autorelease];
}
@end







<


<
<
<



>
|
|
|
<
<
<
<
<
<
|
|
<
<
<

<
<
<
<
<
<
<
|
<
<
|
<
<
<
|
<
<
<
<
<
<
|
<


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


<
|
<
<
<
|
<
<
<
<
<


8
9
10
11
12
13
14

15
16



17
18
19
20
21
22
23






24
25



26







27


28



29






30

31
32


















33
34

35



36





37
38
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#import "OFEnumerator.h"

#import "OFExceptions.h"




@implementation OFEnumerator
- init
{
	if (isa == [OFEnumerator class])
		@throw [OFNotImplementedException newWithClass: isa
						      selector: _cmd];







	return [super init];
}











- (id)nextObject


{



	@throw [OFNotImplementedException newWithClass: isa






					      selector: _cmd];

}



















- reset
{

	@throw [OFNotImplementedException newWithClass: isa



					      selector: _cmd];





}
@end