Dang - a ring buffer. Should have thought of that myself :)
That's certainly the quickest way!
Thanks,
Frank+++
Am 11.04.2007 um 14:25 schrieb Guyren Howe:
> On Apr 11, 2007, at 5:23 AM, Frank Bitterlich wrote:
>
>> 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
>
--
Günter Schmidt GmbH
Frank Bitterlich eMail: [EMAIL PROTECTED]
Ben-Gurion-Ring 21 WWW: http://www.gsco.de/
D-60437 Frankfurt Tel.: 069 / 156809-29
GERMANY Fax: 069 / 156809-28
Geschäftsführer: Jürgen Hartwich
AG Frankfurt am Main, HRB 76504 - USt.-ID: DE235219624
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>