Differences From Artifact [14556b7ee8]:
- File src/OFCountedSet_hashtable.m — part of check-in [e0b9167693] at 2016-02-21 15:37:42 on branch trunk — Make use of C99-style for loops (user: js, size: 4638) [annotate] [blame] [check-ins using]
To Artifact [a4ddef010c]:
- File
src/OFCountedSet_hashtable.m
— part of check-in
[1ba9c051a6]
at
2016-06-04 18:49:46
on branch trunk
— OFMapTable: Rename valueForKey to objectForKey
The reason for this is that -[valueForKey:] could be confused with
Key Value Coding. (user: js, size: 4651) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
144 145 146 147 148 149 150 | count_ = [objectElement attributeForName: @"count"]; if (object == nil || count_ == nil) @throw [OFInvalidFormatException exception]; count = (size_t)[[count_ stringValue] decimalValue]; | | | | | | | | | | | | | | | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 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 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | count_ = [objectElement attributeForName: @"count"]; if (object == nil || count_ == nil) @throw [OFInvalidFormatException exception]; count = (size_t)[[count_ stringValue] decimalValue]; [_mapTable setObject: (void*)(uintptr_t)count forKey: [object objectByDeserializing]]; objc_autoreleasePoolPop(pool2); } objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - (size_t)countForObject: (id)object { return (size_t)(uintptr_t)[_mapTable objectForKey: object]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsAndCountUsingBlock: (of_counted_set_enumeration_block_t)block { @try { [_mapTable enumerateKeysAndObjectsUsingBlock: ^ (void *key, void *object, bool *stop) { block(key, (size_t)(uintptr_t)object, stop); }]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException exceptionWithObject: self]; } } #endif - (void)addObject: (id)object { size_t count = (size_t)(uintptr_t)[_mapTable objectForKey: object]; if (SIZE_MAX - count < 1 || UINTPTR_MAX - count < 1) @throw [OFOutOfRangeException exception]; [_mapTable setObject: (void*)(uintptr_t)(count + 1) forKey: object]; } - (void)removeObject: (id)object { size_t count = (size_t)(uintptr_t)[_mapTable objectForKey: object]; if (count == 0) return; count--; if (count > 0) [_mapTable setObject: (void*)(uintptr_t)count forKey: object]; else [_mapTable removeObjectForKey: object]; } - (void)makeImmutable { } @end |