[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: simple List index question
From: |
Rick Riolo |
Subject: |
Re: simple List index question |
Date: |
Mon, 20 Nov 1995 17:48:59 -0500 (EST) |
Thanks for the info.
re
> position access will be much faster. If you want fast random access
> today, the only way to get it is to allocate your own array of id pointers
> and index that directly in C.
...that's how I got started on trying to subclass List
(so I could have my own local array of pointers into it,
and use that for random access.
- r
Rick Riolo address@hidden
Program for Study of Complex Systems (PSCS)
1061 Randall Lab University of Michigan
Ann Arbor MI 48109-1120
http://pscs.physics.lsa.umich.edu/rlr-home.html
On Mon, 20 Nov 1995, Roger M. Burkhart wrote:
> Date: Mon, 20 Nov 95 14:40:23 CST
> From: Roger M. Burkhart <address@hidden>
> To: address@hidden
> Cc: address@hidden
> Subject: Re: simple List index question
>
> > I just want to check to be sure I am using
> > List indexing correctly. Is the basic idea:
> >
> > id index, other;
> > index = [siteNbors begin: xZone];
> > for ( other=[index next]; other; other=[index next] ) {
> > [other calcE];
> > }
> > [index dropFrom: xZone];
>
> Yes, this is fine. I usually use a while loop rather than a for loop,
> like this:
>
> index = [siteNbors begin: xZone];
> while ( (other = [index next]) ) [other calcE];
> [index dropFrom: xZone];
>
> (The extra parentheses around the assignment used as a while condition are
> needed to suppress a gcc warning under -Wall.)
>
> > As I understand it, when I dropFrom the index,
> > I'm just getting rid of it, not anything in the
> > siteNbors List itself...is that right?
> >
> > Also, am I right that the index and the original List
> > don't have to be in the same zone?
>
> Yes on both. An index is often allocated in a scratch zone for local,
> temporary use and dropped as soon as it is no longer needed. It is intended
> to be a very low overhead object for collection traversal. It always does
> a good job of sequential traversal (forward or backward), but random position
> access (for example, to a random position via [index setOffset: iOffset])
> depends on the underlying implementation. For the current list, this is
> no better than sequentially traversing up to the requested offset. For
> other list implementations and for Array (both to be provided) random
> position access will be much faster. If you want fast random access
> today, the only way to get it is to allocate your own array of id pointers
> and index that directly in C.
>
> Roger
>