︙ | | |
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
-
+
-
-
+
-
-
+
+
+
+
-
+
-
-
+
-
-
+
+
+
+
|
- (id)objectAtIndexedSubscript: (size_t)index
{
return [self objectAtIndex: index];
}
- (size_t)indexOfObject: (id)object
{
size_t i, count;
size_t i = 0;
if (object == nil)
return OF_NOT_FOUND;
count = [self count];
for (id objectIter in self) {
for (i = 0; i < count; i++)
if ([[self objectAtIndex: i] isEqual: object])
if ([objectIter isEqual: object])
return i;
i++;
}
return OF_NOT_FOUND;
}
- (size_t)indexOfObjectIdenticalTo: (id)object
{
size_t i, count;
size_t i = 0;
if (object == nil)
return OF_NOT_FOUND;
count = [self count];
for (id objectIter in self) {
for (i = 0; i < count; i++)
if ([self objectAtIndex: i] == object)
if (objectIter == object)
return i;
i++;
}
return OF_NOT_FOUND;
}
- (bool)containsObject: (id)object
{
return ([self indexOfObject: object] != OF_NOT_FOUND);
|
︙ | | |
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
417
418
419
420
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
449
450
451
452
|
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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
|
-
-
-
-
+
-
-
-
+
-
-
-
-
-
+
+
-
+
-
+
-
-
+
+
+
-
+
-
-
+
-
+
-
-
-
|
options: 0];
}
- (OFString*)componentsJoinedByString: (OFString*)separator
usingSelector: (SEL)selector
options: (int)options
{
void *pool;
OFMutableString *ret;
id const *objects;
size_t i, count;
if (separator == nil)
@throw [OFInvalidArgumentException exception];
count = [self count];
if ([self count] == 0)
if (count == 0)
return @"";
if (count == 1)
if ([self count] == 1)
return [[self firstObject] performSelector: selector];
ret = [OFMutableString string];
pool = objc_autoreleasePoolPush();
objects = [self objects];
if (options & OF_ARRAY_SKIP_EMPTY) {
for (i = 0; i < count; i++) {
void *pool2 = objc_autoreleasePoolPush();
for (id object in self) {
void *pool = objc_autoreleasePoolPush();
OFString *component =
[objects[i] performSelector: selector];
[object performSelector: selector];
if ([component length] > 0) {
if ([ret length] > 0)
[ret appendString: separator];
[ret appendString: component];
}
objc_autoreleasePoolPop(pool2);
objc_autoreleasePoolPop(pool);
}
} else {
for (i = 0; i < count - 1; i++) {
void *pool2 = objc_autoreleasePoolPush();
for (id object in self) {
void *pool = objc_autoreleasePoolPush();
if ([ret length] > 0)
[ret appendString:
[ret appendString: separator];
[objects[i] performSelector: selector]];
[ret appendString: separator];
[ret appendString: [object performSelector: selector]];
objc_autoreleasePoolPop(pool2);
objc_autoreleasePoolPop(pool);
}
[ret appendString: [objects[i] performSelector: selector]];
}
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
}
- (bool)isEqual: (id)object
{
/* FIXME: Optimize (for example, buffer of 16 for each) */
|
︙ | | |
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
|
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
|
-
-
-
-
+
+
|
return false;
return true;
}
- (uint32_t)hash
{
id const *objects = [self objects];
size_t i, count = [self count];
uint32_t hash;
OF_HASH_INIT(hash);
for (i = 0; i < count; i++)
OF_HASH_ADD_HASH(hash, [objects[i] hash]);
for (id object in self)
OF_HASH_ADD_HASH(hash, [object hash]);
OF_HASH_FINALIZE(hash);
return hash;
}
- (OFString*)description
|
︙ | | |
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
|
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
|
-
-
-
+
-
+
|
return [ret autorelease];
}
- (OFXMLElement*)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
id <OFSerialization> const *objects = [self objects];
size_t i, count = [self count];
if ([self isKindOfClass: [OFMutableArray class]])
element = [OFXMLElement elementWithName: @"OFMutableArray"
namespace: OF_SERIALIZATION_NS];
else
element = [OFXMLElement elementWithName: @"OFArray"
namespace: OF_SERIALIZATION_NS];
for (i = 0; i < count; i++) {
for (id object in self) {
void *pool2 = objc_autoreleasePoolPush();
[element addChild: [objects[i] XMLElementBySerializing]];
[element addChild: [object XMLElementBySerializing]];
objc_autoreleasePoolPop(pool2);
}
[element retain];
objc_autoreleasePoolPop(pool);
|
︙ | | |
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
|
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
|
-
-
-
+
-
-
+
-
-
-
+
-
-
-
+
+
|
objc_autoreleasePoolPop(pool);
return data;
}
- (void)makeObjectsPerformSelector: (SEL)selector
{
id const *objects = [self objects];
size_t i, count = [self count];
for (id object in self)
for (i = 0; i < count; i++)
[objects[i] performSelector: selector];
[object performSelector: selector];
}
- (void)makeObjectsPerformSelector: (SEL)selector
withObject: (id)object
{
id const *objects = [self objects];
size_t i, count = [self count];
for (id object in self)
for (i = 0; i < count; i++)
[objects[i] performSelector: selector
withObject: object];
[object performSelector: selector
withObject: object];
}
- (OFArray*)sortedArray
{
OFMutableArray *new = [[self mutableCopy] autorelease];
[new sort];
|
︙ | | |