ObjFW  Diff

Differences From Artifact [bd2462ab4e]:

To Artifact [b5ab4c9ae4]:


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
353
354
355

356
357
358
359
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
402
403

404
405
406
407
408
409

410
411
412
413
414
415
416
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
353
354

355
356
357
358
359
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
402

403
404
405
406
407
408

409
410
411
412
413
414
415
416







-
+







-
+




-
+










-
+





-
+


-
+






-
+







-
+





-
+


-
+






-
+







-
+





-
+







}

- mutableCopy
{
	return [[OFMutableDictionary alloc] initWithDictionary: self];
}

- (BOOL)isEqual: (id)object
- (bool)isEqual: (id)object
{
	OFDictionary *otherDictionary;
	void *pool;
	OFEnumerator *enumerator;
	id key;

	if (![object isKindOfClass: [OFDictionary class]])
		return NO;
		return false;

	otherDictionary = object;

	if ([otherDictionary count] != [self count])
		return NO;
		return false;

	pool = objc_autoreleasePoolPush();

	enumerator = [self keyEnumerator];
	while ((key = [enumerator nextObject]) != nil) {
		id object = [otherDictionary objectForKey: key];

		if (object == nil ||
		    ![object isEqual: [self objectForKey: key]]) {
			objc_autoreleasePoolPop(pool);
			return NO;
			return false;
		}
	}

	objc_autoreleasePoolPop(pool);

	return YES;
	return true;
}

- (BOOL)containsObject: (id)object
- (bool)containsObject: (id)object
{
	void *pool;
	OFEnumerator *enumerator;
	id currentObject;

	if (object == nil)
		return NO;
		return false;

	pool = objc_autoreleasePoolPush();
	enumerator = [self objectEnumerator];

	while ((currentObject = [enumerator nextObject]) != nil) {
		if ([currentObject isEqual: object]) {
			objc_autoreleasePoolPop(pool);
			return YES;
			return true;
		}
	}

	objc_autoreleasePoolPop(pool);

	return NO;
	return false;
}

- (BOOL)containsObjectIdenticalTo: (id)object
- (bool)containsObjectIdenticalTo: (id)object
{
	void *pool;
	OFEnumerator *enumerator;
	id currentObject;

	if (object == nil)
		return NO;
		return false;

	pool = objc_autoreleasePoolPush();
	enumerator = [self objectEnumerator];

	while ((currentObject = [enumerator nextObject]) != nil) {
		if (currentObject == object) {
			objc_autoreleasePoolPop(pool);
			return YES;
			return true;
		}
	}

	objc_autoreleasePoolPop(pool);

	return NO;
	return false;
}

- (OFArray*)allKeys
{
	void *pool = objc_autoreleasePoolPush();
	id *keys = [self allocMemoryWithSize: sizeof(id)
				       count: [self count]];
485
486
487
488
489
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
485
486
487
488
489
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







-
+
















-
+















-
+







	abort();
}

#if defined(OF_HAVE_BLOCKS) && defined(OF_HAVE_FAST_ENUMERATION)
- (void)enumerateKeysAndObjectsUsingBlock:
    (of_dictionary_enumeration_block_t)block
{
	BOOL stop = NO;
	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) {
	    bool *stop) {
		[new setObject: block(key, object)
			forKey: key];
	}];

	[new makeImmutable];

	return new;
}

- (OFDictionary*)filteredDictionaryUsingBlock:
    (of_dictionary_filter_block_t)block
{
	OFMutableDictionary *new = [OFMutableDictionary dictionary];

	[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
	    BOOL *stop) {
	    bool *stop) {
		if (block(key, object))
			[new setObject: object
				forKey: key];
	}];

	[new makeImmutable];