>> I need to maintain an integer array to be used as a FIFO stack. I >> will .append() up to 10000 values, and when the array reaches that >> size, I will "cut off" the oldest (lowest) 5000 entries. Right now >> I'm doing this by using .remove() in a loop. >> >> The thing needs to be as time-efficient as possible, so I wonder if >> it would be more efficient if I created a new array and copied over >> the last 5000, rather than removing the first 5000. >> >> Has anybody experience with this kind of operations, so that I don't >> need to test it on my own? >> > > The fastest solution given what you've described would be an array of > 10,000 elements (or even a memory block, depending on what types of > values they are), which you don't resize. Instead, you would keep > head and tail position values, and maintain everything that way. When > you reached the end of the array, you'd wrap around the other side. > > Does that make sense. > > 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 > > Howdy, I'm afraid I didn't quite follow what you mean there. Could someone post a simple example?
Thanks, Fargo _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
