>>> 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 > Ahhhh, ok. See, now that I've had a day of colas and naps while commuting, I finally understand. I didn't realize you were talking about just re-using the elements, but instead had imagined that you were speaking of still reading and removing elements.
That's really handy. I vaguely recall doing something like that with a bitfield in C/C++, but it had faded way into the background to join other concepts I'd learned and never used enough. Thanks, Fargo _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
