ObjFW  Diff

Differences From Artifact [1a4ab06f2b]:

To Artifact [7d79beb13c]:

  • File src/OFIterator.h — part of check-in [24ecf55297] at 2009-06-29 12:33:59 on branch trunk — Changes to OFDictionary, OFIterator and OFList - see details.

    OFDictionary:
    * More optimized way to internally store the data.
    * Faster resizing of dictionaries (no rehashing anymore).

    OFIterator:
    * Return a key/object pair rather than first the key and then the
    object.

    OFList:
    * Support for list objects with a different size so you can have your
    own list object structs. (user: js, size: 1069) [annotate] [blame] [check-ins using]


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
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFObject.h"
#import "OFList.h"
#import "OFDictionary.h"






extern int _OFIterator_reference;

/**
 * The OFIterator class provides methods to iterate through objects.
 */
@interface OFIterator: OFObject
{
	OFList		 **data;
	size_t		 size;
	size_t		 pos;
	of_list_object_t *last;
}

- initWithData: (OFList**)data
       andSize: (size_t)size;

/**
 * Returns the next object in the dictionary.
 *
 * Always call it twice in a row, as it returns the key on the first call and
 * the value on the second. Therefore, if you want a key value pair, you have
 * to call:
 *
 * key = [iter nextObject];\n
 * value = [iter nextObject];
 *
 * When there is no more object left, an OFNotInSetException is thrown.
 *
 * \return The key on the first call and the value on the second
 */
- (id)nextObject;

/**
 * Resets the iterator, so the next call to nextObject returns the first again.
 */
- reset;
@end

@interface OFDictionary (OFIterator)
/**
 * \return An OFIterator for the OFDictionary
 */
- (OFIterator*)iterator;
@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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFObject.h"
#import "OFList.h"
#import "OFDictionary.h"

typedef struct __of_iterator_pair {
	id key;
	id object;
} of_iterator_pair_t;

extern int _OFIterator_reference;

/**
 * The OFIterator class provides methods to iterate through objects.
 */
@interface OFIterator: OFObject
{
	OFList		 **data;
	size_t		 size;
	size_t			    pos;
	of_dictionary_list_object_t *last;
}

- initWithData: (OFList**)data
       andSize: (size_t)size;

/**











 * \return A struct containing the next key and object
 */
- (of_iterator_pair_t)nextKeyObjectPair;

/**
 * Resets the iterator, so the next call to nextObject returns the first again.
 */
- reset;
@end

@interface OFDictionary (OFIterator)
/**
 * \return An OFIterator for the OFDictionary
 */
- (OFIterator*)iterator;
@end