[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: storing ids
From: |
Chris B. Vetter |
Subject: |
Re: storing ids |
Date: |
Thu, 29 May 2003 10:37:47 -0700 |
On Thu, 29 May 2003 16:08:19 GMT
reuss <reuss@chello.hu> wrote:
> in gnustep, which method to use to store and reference object by id?
> NSArray? NSEnumerator?
> own linkedlist? own stack implementation?
> other?
That depends on what you want to store and/or how those are implemented.
As an example how to implement a Stack and a Queue, you might want to
take a look at
http://www.knuddel.org/Projects/KoKit/Documentation/KoFoundation/KFStack.html
http://www.knuddel.org/Projects/KoKit/Documentation/KoFoundation/KFQueue.html
and the respective source in CVS.
> is it a wrong solution?
> NSMutableArray *anArray;
> anArray=[NSMutableArray new[;
> id anObject=[[MyObject alloc]init];
> for(i=0;i<10000000000;i++)
> [anArray addObject: [anObject newWithValuw: i]];
Assuming that -newWithValue: returns an object, this would be correct,
although 10000000000 might result in an overflow.
I wouldn't call the method _new_WithValue:, as the 'new' implies a new
instance of MyObject, instead [anObject addValue: i] or [anObject
addInteger: i] (addFloat: addLong: ... you get the idea) would be a
better name.
--
Chris
- storing ids, reuss, 2003/05/29
- Re: storing ids,
Chris B. Vetter <=