On Apr 11, 2007, at 12:56 PM, Fargo Holiday wrote:

>> Imagine the 10,000 elements are arranged, not in a line, but in a
>> circle. You keep track of two numbers, representing where in the
>> circle the head and tail of your list are. When these meet, you
>> extract the first 5,000 elements from the list, moving the tail up.
>> Now, because it's a ring, you have room in front of the head of the
>> list for another 5,000 elements. Lather, rinse and repeat.
>>
> Ah, ok. Too simple for my un-caffeinated mind. Here's another
> "brilliant" question to display the depth of my experience: What is  
> the
> advantage of doing it this way, versus a looping remove? Don't you end
> up doing essentially the same task when extracting?

The original question was about speed. This is fast because you don't  
have to shift or even remove elements. You just move the head and  
tail pointers around and reuse the elements of the array. You could  
just naively use the array, rediming and whatever you want to. But  
this will be hundreds of times faster than that.

Regards,

Guyren G Howe
Relevant Logic LLC

guyren-at-relevantlogic.com ~ http://relevantlogic.com

REALbasic, PHP, Ruby/Rails, Python programming
PostgreSQL, MySQL database design and consulting
Technical writing and training


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to