[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using indexes [Solaris 2.6, Swarm 1.2]
From: |
Michael Whidden |
Subject: |
Re: Using indexes [Solaris 2.6, Swarm 1.2] |
Date: |
Thu, 22 Oct 1998 13:38:53 -0400 |
I avoid the 'atOffset' loop, because a quick look at the
code (I use Swarm 1.1) shows that it is very inefficient in a loop.
(It allocs memory, scans the whole list up to offset 'i', and then
releases the memory.)
An index loop is much faster. Try one of the latter two.
Gary Polhill wrote:
> statically typing lp3 to LandParcel? Does anyone have any thoughts
> on what the best way to traverse a list is? Or any thoughts on which
> is better (in terms of efficiency/elegance/readability) of the
> following:
>
> for(i = 0; i < [aList getCount]; i++) {
> member = [aList atOffset: i];
>
> // do your stuff
> }
>
> for(anIndex = [aList begin: aZone], [anIndex next];
> [anIndex getLoc] == Member;
> [anIndex next])
> {
> member = [anIndex get];
>
> // do your stuff
> }
>
> Of course, if there is no bug in -next, then you could do:
>
> for(anIndex = [aList begin: aZone], member = [anIndex next];
> [anIndex getLoc == Member;
> member = [anIndex next])
> {
> // do your stuff
> }
--
Michael Whidden Lockheed Martin Information Systems
Phone: (781) 505-9542 Advanced Simulation Center
Fax: (781) 505-9501 37 North Ave
Email: address@hidden Burlington, MA 01803
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
==================================