︙ | | |
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
-
+
-
-
-
+
+
+
+
+
-
+
-
-
+
|
return [[OFMutableDictionary alloc] initWithDictionary: self];
}
- (bool)isEqual: (id)object
{
OFDictionary *otherDictionary;
void *pool;
OFEnumerator *enumerator;
OFEnumerator *keyEnumerator, *objectEnumerator;
id key;
if (![object isKindOfClass: [OFDictionary class]])
return false;
otherDictionary = object;
if ([otherDictionary count] != [self count])
return false;
pool = objc_autoreleasePoolPush();
enumerator = [self keyEnumerator];
while ((key = [enumerator nextObject]) != nil) {
id object = [otherDictionary objectForKey: key];
keyEnumerator = [self keyEnumerator];
objectEnumerator = [self objectEnumerator];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil) {
id otherObject = [otherDictionary objectForKey: key];
if (object == nil ||
if (otherObject == nil || ![otherObject isEqual: object]) {
![object isEqual: [self objectForKey: key]]) {
objc_autoreleasePoolPop(pool);
return false;
}
}
objc_autoreleasePoolPop(pool);
return true;
}
- (bool)containsObject: (id)object
{
void *pool;
OFEnumerator *enumerator;
id currentObject;
if (object == nil)
return false;
pool = objc_autoreleasePoolPush();
enumerator = [self objectEnumerator];
enumerator = [self objectEnumerator];
while ((currentObject = [enumerator nextObject]) != nil) {
if ([currentObject isEqual: object]) {
objc_autoreleasePoolPop(pool);
return true;
}
}
|
︙ | | |
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
|
-
+
-
-
-
-
+
-
-
|
OFEnumerator *enumerator;
id currentObject;
if (object == nil)
return false;
pool = objc_autoreleasePoolPush();
enumerator = [self objectEnumerator];
enumerator = [self objectEnumerator];
while ((currentObject = [enumerator nextObject]) != nil) {
if (currentObject == object) {
objc_autoreleasePoolPop(pool);
return true;
}
}
objc_autoreleasePoolPop(pool);
return false;
}
- (OFArray*)allKeys
{
OFMutableArray *ret = [OFMutableArray arrayWithCapacity: [self count]];
void *pool = objc_autoreleasePoolPush();
OFEnumerator *enumerator = [self keyEnumerator];
id key;
while ((key = [enumerator nextObject]) != nil)
for (id key in self)
[ret addObject: key];
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
}
- (OFArray*)allObjects
{
OFMutableArray *ret = [OFMutableArray arrayWithCapacity: [self count]];
void *pool = objc_autoreleasePoolPush();
|
︙ | | |
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
|
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
|
-
+
-
-
|
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
objects: (id*)objects
count: (int)count_
{
OF_UNRECOGNIZED_SELECTOR
}
#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION)
#ifdef OF_HAVE_BLOCKS
- (void)enumerateKeysAndObjectsUsingBlock:
(of_dictionary_enumeration_block_t)block
{
bool stop = false;
for (id key in self) {
block(key, [self objectForKey: key], &stop);
if (stop)
break;
}
}
#endif
#ifdef OF_HAVE_BLOCKS
- (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block
{
OFMutableDictionary *new = [OFMutableDictionary dictionary];
[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
bool *stop) {
[new setObject: block(key, object)
|
︙ | | |
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
|
-
-
+
+
+
+
-
+
-
+
|
return new;
}
#endif
- (uint32_t)hash
{
void *pool = objc_autoreleasePoolPush();
OFEnumerator *enumerator = [self keyEnumerator];
id key;
OFEnumerator *keyEnumerator = [self keyEnumerator];
OFEnumerator *objectEnumerator = [self objectEnumerator];
id key, object;
uint32_t hash = 0;
while ((key = [keyEnumerator nextObject]) != nil &&
while ((key = [enumerator nextObject]) != nil) {
(object = [objectEnumerator nextObject]) != nil) {
hash += [key hash];
hash += [[self objectForKey: key] hash];
hash += [object hash];
}
objc_autoreleasePoolPop(pool);
return hash;
}
|
︙ | | |