Overview
Comment: | Add -[OFMutableDictionary removeAllObjects]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
aae02e7970e634a194734e7a647241b5 |
User & Date: | js on 2013-08-10 23:12:07 |
Other Links: | manifest | tags |
Context
2013-08-12
| ||
10:00 | Don't store the first 128 chars of an encoding. check-in: d36cf257fe user: js tags: trunk | |
2013-08-10
| ||
23:12 | Add -[OFMutableDictionary removeAllObjects]. check-in: aae02e7970 user: js tags: trunk | |
2013-08-08
| ||
23:21 | OFArray: Add forgotten ivar prefix. check-in: a3b6cca867 user: js tags: trunk | |
Changes
Modified src/OFMapTable.h from [bef3845de0] to [260a69baad].
︙ | ︙ | |||
152 153 154 155 156 157 158 159 160 161 162 163 164 165 | /*! * @brief Removes the value for the specified key from the map table. * * @param key The key whose object should be removed */ - (void)removeValueForKey: (void*)key; /*! * @brief Checks whether the map table contains a value equal to the specified * value. * * @param value The value which is checked for being in the map table * @return A boolean whether the map table contains the specified value */ | > > > > > | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | /*! * @brief Removes the value for the specified key from the map table. * * @param key The key whose object should be removed */ - (void)removeValueForKey: (void*)key; /*! * @brief Removes all values. */ - (void)removeAllValues; /*! * @brief Checks whether the map table contains a value equal to the specified * value. * * @param value The value which is checked for being in the map table * @return A boolean whether the map table contains the specified value */ |
︙ | ︙ |
Modified src/OFMapTable.m from [40dcf1c644] to [360a62d844].
︙ | ︙ | |||
490 491 492 493 494 495 496 497 498 499 500 501 502 503 | _mutations++; [self OF_resizeForCount: _count]; return; } } } - (bool)containsValue: (void*)value { uint32_t i; if (value == NULL || _count == 0) return false; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | _mutations++; [self OF_resizeForCount: _count]; return; } } } - (void)removeAllValues { uint32_t i; for (i = 0; i < _capacity; i++) { if (_buckets[i] != NULL) { if (_buckets[i] == &deleted) { _buckets[i] = NULL; continue; } _keyFunctions.release(_buckets[i]->key); _valueFunctions.release(_buckets[i]->value); [self freeMemory: _buckets[i]]; _buckets[i] = NULL; } } _count = 0; _capacity = MIN_CAPACITY; _buckets = [self resizeMemory: _buckets size: sizeof(*_buckets) count: _capacity]; /* * Get a new random value for _rotate, so that it is not less secure * than creating a new hash map. */ if (of_hash_seed != 0) #if defined(HAVE_ARC4RANDOM) _rotate = arc4random() & 31; #elif defined(HAVE_RANDOM) _rotate = random() & 31; #else _rotate = rand() & 31; #endif } - (bool)containsValue: (void*)value { uint32_t i; if (value == NULL || _count == 0) return false; |
︙ | ︙ |
Modified src/OFMutableDictionary.h from [478ab9b477] to [5a99684d1c].
︙ | ︙ | |||
67 68 69 70 71 72 73 74 75 76 77 78 79 80 | /*! * @brief Removes the object for the specified key from the dictionary. * * @param key The key whose object should be removed */ - (void)removeObjectForKey: (id)key; #ifdef OF_HAVE_BLOCKS /*! * @brief Replaces each object with the object returned by the block. * * @param block The block which returns a new object for each object */ - (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block; | > > > > > | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | /*! * @brief Removes the object for the specified key from the dictionary. * * @param key The key whose object should be removed */ - (void)removeObjectForKey: (id)key; /*! * @brief Removes all objects. */ - (void)removeAllObjects; #ifdef OF_HAVE_BLOCKS /*! * @brief Replaces each object with the object returned by the block. * * @param block The block which returns a new object for each object */ - (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block; |
︙ | ︙ |
Modified src/OFMutableDictionary.m from [c0b80ff39c] to [09dfaa10d0].
︙ | ︙ | |||
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include "config.h" #include <stdlib.h> #import "OFMutableDictionary_hashtable.h" static struct { Class isa; } placeholder; @interface OFMutableDictionary_placeholder: OFDictionary @end | > > | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include "config.h" #include <stdlib.h> #import "OFMutableDictionary_hashtable.h" #import "autorelease.h" static struct { Class isa; } placeholder; @interface OFMutableDictionary_placeholder: OFDictionary @end |
︙ | ︙ | |||
185 186 187 188 189 190 191 192 193 194 195 196 197 198 | } - (void)removeObjectForKey: (id)key { [self doesNotRecognizeSelector: _cmd]; abort(); } - copy { return [[OFDictionary alloc] initWithDictionary: self]; } #ifdef OF_HAVE_BLOCKS | > > > > > > > > > > > > > | 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 | } - (void)removeObjectForKey: (id)key { [self doesNotRecognizeSelector: _cmd]; abort(); } - (void)removeAllObjects { void *pool = objc_autoreleasePoolPush(); OFArray *keys = [self allKeys]; OFEnumerator *enumerator = [keys objectEnumerator]; id key; while ((key = [enumerator nextObject]) != nil) [self removeObjectForKey: key]; objc_autoreleasePoolPop(pool); } - copy { return [[OFDictionary alloc] initWithDictionary: self]; } #ifdef OF_HAVE_BLOCKS |
︙ | ︙ |
Modified src/OFMutableDictionary_hashtable.m from [697582eaa4] to [edd5ea5ceb].
︙ | ︙ | |||
41 42 43 44 45 46 47 48 49 50 51 52 53 54 | forKey: key]; } - (void)removeObjectForKey: (id)key { [_mapTable removeValueForKey: key]; } #ifdef OF_HAVE_BLOCKS - (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block { @try { [_mapTable replaceValuesUsingBlock: ^ void* (void *key, void *value) { | > > > > > | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | forKey: key]; } - (void)removeObjectForKey: (id)key { [_mapTable removeValueForKey: key]; } - (void)removeAllObjects { [_mapTable removeAllValues]; } #ifdef OF_HAVE_BLOCKS - (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block { @try { [_mapTable replaceValuesUsingBlock: ^ void* (void *key, void *value) { |
︙ | ︙ |