Differences From Artifact [1f61a324ed]:
- File
src/OFMapTable.m
— part of check-in
[4fb0f4bf66]
at
2013-02-18 11:07:29
on branch trunk
— Add -[OFMutableDictionary initWithCapacity:].
This was already implemented in OFDictionary_hashtable for internal
usage and is now publicly available. (user: js, size: 16106) [annotate] [blame] [check-ins using]
To Artifact [f2d7d60333]:
- File
src/OFMapTable.m
— part of check-in
[c5ef582958]
at
2013-03-04 17:20:15
on branch trunk
— Replace BOOL with bool.
The only places where BOOL is left are those where they are required by
the ABI. (user: js, size: 16136) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
51 52 53 54 55 56 57 | static uint32_t default_hash(void *value) { return (uint32_t)(uintptr_t)value; } | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | static uint32_t default_hash(void *value) { return (uint32_t)(uintptr_t)value; } static bool default_equal(void *value1, void *value2) { return (value1 == value2); } @interface OFMapTableKeyEnumerator: OFMapTableEnumerator @end |
︙ | ︙ | |||
178 179 180 181 182 183 184 | _valueFunctions.release(_buckets[i]->value); } } [super dealloc]; } | | | | | | | 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 | _valueFunctions.release(_buckets[i]->value); } } [super dealloc]; } - (bool)isEqual: (id)object { OFMapTable *mapTable; uint32_t i; if (![object isKindOfClass: [OFMapTable class]]) return false; mapTable = object; if (mapTable->_count != _count || mapTable->_keyFunctions.equal != _keyFunctions.equal || mapTable->_valueFunctions.equal != _valueFunctions.equal) return false; for (i = 0; i < _capacity; i++) { if (_buckets[i] != NULL && _buckets[i] != &deleted) { void *value = [mapTable valueForKey: _buckets[i]->key]; if (!_valueFunctions.equal(value, _buckets[i]->value)) return false; } } return true; } - (uint32_t)hash { uint32_t i, hash = 0; for (i = 0; i < _capacity; i++) { |
︙ | ︙ | |||
500 501 502 503 504 505 506 | [self OF_resizeForCount: _count]; return; } } } | | | | | | | | | | 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 | [self OF_resizeForCount: _count]; return; } } } - (bool)containsValue: (void*)value { uint32_t i; if (value == NULL || _count == 0) return false; for (i = 0; i < _capacity; i++) if (_buckets[i] != NULL && _buckets[i] != &deleted) if (_valueFunctions.equal(_buckets[i]->value, value)) return true; return false; } - (bool)containsValueIdenticalTo: (void*)value { uint32_t i; if (value == NULL || _count == 0) return false; for (i = 0; i < _capacity; i++) if (_buckets[i] != NULL && _buckets[i] != &deleted) if (_buckets[i]->value == value) return true; return false; } - (OFMapTableEnumerator*)keyEnumerator { return [[[OFMapTableKeyEnumerator alloc] OF_initWithMapTable: self buckets: _buckets |
︙ | ︙ | |||
578 579 580 581 582 583 584 | } #ifdef OF_HAVE_BLOCKS - (void)enumerateKeysAndValuesUsingBlock: (of_map_table_enumeration_block_t)block { size_t i; | | | | 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | } #ifdef OF_HAVE_BLOCKS - (void)enumerateKeysAndValuesUsingBlock: (of_map_table_enumeration_block_t)block { size_t i; bool stop = false; unsigned long mutations = _mutations; for (i = 0; i < _capacity && !stop; i++) { if (_mutations != mutations) @throw [OFEnumerationMutationException exceptionWithClass: [self class] object: self]; if (_buckets[i] != NULL && _buckets[i] != &deleted) block(_buckets[i]->key, _buckets[i]->value, &stop); } } - (void)replaceValuesUsingBlock: (of_map_table_replace_block_t)block { size_t i; bool stop = false; unsigned long mutations = _mutations; for (i = 0; i < _capacity && !stop; i++) { if (_mutations != mutations) @throw [OFEnumerationMutationException exceptionWithClass: [self class] object: self]; |
︙ | ︙ |