Re: WTF? How can this work?
Re: WTF? How can this work?
- Subject: Re: WTF? How can this work?
- From: Ondra Cada <email@hidden>
- Date: Mon, 20 Aug 2001 15:20:18 +0200
John,
>
>>>>> John C. Randolph (JCR) wrote at Mon, 20 Aug 2001 05:59:03 -0700:
JCR> >I would really pledge to the very opposite: my point of view is that
JCR> >cluttering Foundation with utterly unneeded classes whose functionality
JCR> >is just a subset of others would not help anybody.
JCR>
JCR> First, a FIFO is not a subset of what the other container classes do.
It is. See below.
JCR> Second, it's a suitable addition to Foundation, because it's something
JCR> that a lot of people have to do over and over again.
Nope. The following code is NOT, repeat NOT worth a special API:
#define NSFIFOArray NSArray
// use addObject: to add an object
@implementation NSMutableArray (NSFIFOTotallyUnnecessaryCategory)
-firstObject { return [self objectAtIndex:0]; }
-returnAndRemoveFirstObject {
id val=[[self objectAtIndex:0] retain];
[self removeObjectAtIndex:0];
return [val autorelease];
}
@end
It is so simple and transparent that it is, actually, not worth the category
either -- it is more convenient just to use the NSMutableArray API directly.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
- Follow-Ups:
- FIFOs.
- From: "John C. Randolph" <email@hidden>