Re: red black trees
Re: red black trees
- Subject: Re: red black trees
- From: Allan Odgaard <email@hidden>
- Date: Thu, 19 Feb 2004 13:11:48 +0100
On 19. Feb 2004, at 11:29, Marco Scheurer wrote:
Arg... implementing algorithms in ObjC is certainly not something I
would recommend, not really for the performance overhead, but mainly
for the syntactic overhead [...]
Argh! I would have said exactly the opposite, ie one always want to
avoid the syntactic mess of C++. [...]
Not that I wish to start a flame war or anything, but would you care to
elaborate?
I mean, in C++ you compare types like:
if(a < b)
...
In Cocoa/ObjC that is
if([a compare:b] == NSOrderedAscending)
...
In C++ you can write:
MyType t1 = t2 + t3;
In ObjC that would be something like:
MyType* t1 = [t2 mutableCopy];
[t1 add:t3];
...
[t1 release];
In C++ you can write:
struct MyType {
int value;
MyType (int i) { value = i; }
};
std::vector<MyType> v;
v.push_back(32);
v.push_back(64);
In ObjC you would do:
@interface MyType : NSObject
{
int value;
}
@end
@implementation MyType
- (id)initWithInt:(int)i
{
if(self = [super init])
value = i;
return self;
}
@end
NSMutableArray* a = [NSMutableArray array];
[a addObject:[[[MyType alloc] initWithInt:32] autorelease]];
[a addObject:[[[MyType alloc] initWithInt:64] autorelease]];
And so on... not to mention all the standard algorithms available in
C++...
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.