Differences From Artifact [6e8102a07c]:
- File src/OFIterator.m — part of check-in [42e16978dc] at 2009-07-19 16:01:21 on branch trunk — Prevent calling -[init] if parameters are required. (user: js, size: 1509) [annotate] [blame] [check-ins using]
To Artifact [d7091488bd]:
- File
src/OFIterator.m
— part of check-in
[bbf1f79b8f]
at
2009-09-08 16:06:10
on branch trunk
— New OFDictionary implementation and removal of a hack in OFList.
The new implementation is easier to use as it does automatic resizing,
but therefore it's not realtime-capable anymore. The new implementation
should also be a little bit faster.I decided to change the implementation as only very few need a
realtime-capable dictionary and those few will most likely write their
own implementation for their specific case anyway.As the new implementation no longer uses OFList, this also made it
possible to remove a hack from OFList. (user: js, size: 1644) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
21 22 23 24 25 26 27 | @implementation OFIterator - init { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } | | > > < > > > > > > > | > | | | < < | | | < < | | | > > | < | < > | | > | | | > > | | | | > < | 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 | @implementation OFIterator - 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_iterator_pair_t)nextKeyObjectPair { of_iterator_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 (OFIterator) - (OFIterator*)iterator { return [[[OFIterator alloc] initWithData: data size: size] autorelease]; } @end |