Overview
Comment: | Add another convenience method for OFDictionary. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
5d9ea7b9cc4a98e793748033a9b66fe9 |
User & Date: | js on 2009-05-18 22:47:34 |
Other Links: | manifest | tags |
Context
2009-05-18
| ||
23:08 | Fix memset on wrong variable in OFMutableDictionary. check-in: 98f2fa06d0 user: js tags: trunk | |
22:47 | Add another convenience method for OFDictionary. check-in: 5d9ea7b9cc user: js tags: trunk | |
22:21 | Add a new convenience method for OFDictionary. check-in: b02800172f user: js tags: trunk | |
Changes
Modified src/OFDictionary.h from [8dfc026fb1] to [966817c8c7].
︙ | |||
35 36 37 38 39 40 41 | 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 | - + + + + + + + + + + + | * * \param bits The size of the hash to use * \return A new autoreleased OFDictionary */ + dictionaryWithHashSize: (int)hashsize; /** |
︙ | |||
58 59 60 61 62 63 64 | 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 100 101 102 103 | - + + + + + + + + + + + + + - + + | * * \param bits The size of the hash to use * \return An initialized OFDictionary */ - initWithHashSize: (int)hashsize; /** |
︙ |
Modified src/OFDictionary.m from [e1fdd39466] to [bbacfd711b].
︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | + + + + + + + | return [[[self alloc] init] autorelease]; } + dictionaryWithHashSize: (int)hashsize { return [[[self alloc] initWithHashSize: hashsize] autorelease]; } + dictionaryWithKey: (OFObject <OFCopying>*)key andObject: (OFObject*)obj { return [[[self alloc] initWithKey: key andObject: obj] autorelease]; } + dictionaryWithKeysAndObjects: (OFObject <OFCopying>*)first, ... { id ret; va_list args; va_start(args, first); |
︙ | |||
95 96 97 98 99 100 101 102 103 104 105 106 107 108 | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 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 152 153 154 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | [self dealloc]; @throw e; } memset(data, 0, size * sizeof(OFList*)); return self; } - initWithKey: (OFObject <OFCopying>*)key andObject: (OFObject*)obj { Class c; uint32_t hash; self = [self init]; if (key == nil || obj == nil) { c = isa; [self dealloc]; @throw [OFInvalidArgumentException newWithClass: isa andSelector: _cmd]; } hash = [key hash] & (size - 1); @try { key = [key copy]; } @catch (OFException *e) { [self dealloc]; @throw e; } @try { data[hash] = [[OFList alloc] init]; [data[hash] append: key]; [data[hash] append: obj]; } @catch (OFException *e) { [self dealloc]; @throw e; } @finally { [key release]; } return self; } - initWithKeysAndObjects: (OFObject <OFCopying>*)first, ... { id ret; va_list args; va_start(args, first); |
︙ | |||
119 120 121 122 123 124 125 | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | - + + + - + + + + + | id key, obj; Class c; uint32_t hash; self = [self init]; obj = va_arg(args, id); |
︙ |
Modified tests/OFDictionary/OFDictionary.m from [1082626ba9] to [cda6d24680].
︙ | |||
15 16 17 18 19 20 21 22 23 24 25 | 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | + + + + - + - + + - + + - + + - + + + + + + + + - - + + + - - + + - + - - - - - + + - - + + + + + + + + + + + + - - + + - + | #include <string.h> #import "OFAutoreleasePool.h" #import "OFDictionary.h" #import "OFString.h" #import "OFExceptions.h" #define TESTS 10 int main() { int i = 0; OFDictionary *dict = [OFMutableDictionary dictionaryWithHashSize: 16]; |