Re: Writing a linked list
Re: Writing a linked list
- Subject: Re: Writing a linked list
- From: Lloyd Dupont <email@hidden>
- Date: Fri, 21 Mar 2003 16:31:00 +1100
struct CLinkList
{
// appropriate fields
};
@interface MyLinkedList : NSObject
{
struct CLinkList myList, *pMyList;
}
@end
@implementation MyLinkedList
- (id) init
{
pMyList = (struct CLinkList *) malloc(sizeof(strcut CLinkList));
// init ....
return self;
}
- (void) dealloc
{
free(pMyList);
}
@end
of course, better than embed the struct it would be much better if the
ObjC object IS your object !
like this.....
@interface MyLinkedList : NSObject
{
// example of appropriate field
void * startNode;
}
@end
@implementation MyLinkedList
- (id) init
{
startNode = NULL;
return self;
}
- (void) dealloc
{
if(startNode) {
}
}
@end
On Friday, March 21, 2003, at 04:19 PM, Britt Green wrote:
I'm trying to convert my C++ Linked List class into Obj C, to better
learn the latter. However I'm having a hard time finding assistance on
doing this. I was wondering if anyone could point me to any examples of
this, or at least tell me if I can embed a C-style struct as a private
data member in a class?
Thanks!
Britt
PS: I am aware of the NSArray class but I just want to write my own
linked list as an academic exercise.
=====
"The ocean, she is strange and wonderous, filled with animals that
disturb even a Frenchman."
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com
_______________________________________________
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.
_______________________________________________
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.