Differences From Artifact [a1a71dda9a]:
- File src/OFDictionary.h — part of check-in [4eae61a78f] at 2009-07-19 14:05:30 on branch trunk — Rename andFoo: to foo: in all methods. (user: js, size: 4244) [annotate] [blame] [check-ins using]
To Artifact [27b0d8980d]:
- File
src/OFDictionary.h
— 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: 3450) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
8 9 10 11 12 13 14 | * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #include <stdarg.h> #import "OFObject.h" | < | | < < | < < | < > | | > | < < < < < < < < | 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 | * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #include <stdarg.h> #import "OFObject.h" #import "OFArray.h" struct of_dictionary_bucket { OFObject <OFCopying> *key; OFObject *object; uint32_t hash; }; /** * The OFDictionary class provides a class for using hash tables. */ @interface OFDictionary: OFObject <OFCopying, OFMutableCopying> { struct of_dictionary_bucket *data; size_t size; size_t count; } /** * Creates a new OFDictionary. * * \return A new autoreleased OFDictionary */ + dictionary; /** * Creates a new OFDictionary with the specified dictionary. * * \param dict An OFDictionary * \return A new autoreleased OFDictionary */ + dictionaryWithDictionary: (OFDictionary*)dict; /** * Creates a new OFDictionary with the specified key and object. * * \param key The key * \param obj The object * \return A new autoreleased OFDictionary */ |
︙ | ︙ | |||
77 78 79 80 81 82 83 | */ + dictionaryWithObjects: (OFArray*)objs forKeys: (OFArray*)keys; /** * Creates a new OFDictionary with the specified keys objects. * | | | | < < < < < < < < | 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 97 98 99 | */ + dictionaryWithObjects: (OFArray*)objs forKeys: (OFArray*)keys; /** * Creates a new OFDictionary with the specified keys objects. * * \param key The first key * \return A new autoreleased OFDictionary */ + dictionaryWithKeysAndObjects: (OFObject <OFCopying>*)key, ...; /** * Initializes an already allocated OFDictionary. * * \return An initialized OFDictionary */ - init; /** * Initializes an already allocated OFDictionary with the specified * OFDictionary. * * \param dict An OFDictionary * \return An initialized OFDictionary */ - initWithDictionary: (OFDictionary*)dict; /** * Initializes an already allocated OFDictionary with the specified key and * object. * * \param key The key * \param obj The object * \return A new initialized OFDictionary |
︙ | ︙ | |||
147 148 149 150 151 152 153 | * * \param first The first key * \return A new initialized OFDictionary */ - initWithKey: (OFObject <OFCopying>*)first argList: (va_list)args; | < < < < < < < | > > > > > < | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | * * \param first The first key * \return A new initialized OFDictionary */ - initWithKey: (OFObject <OFCopying>*)first argList: (va_list)args; /** * \param key The key whose object should be returned * \return The object for the given key or nil if the key was not found */ - (id)objectForKey: (OFObject <OFCopying>*)key; /** * \return The number of objects in the dictionary */ - (size_t)count; - setObject: (OFObject*)obj forKey: (OFObject <OFCopying>*)key; - removeObjectForKey: (OFObject*)key; @end #import "OFIterator.h" #import "OFMutableDictionary.h" |