Are there Python code for a FIFO-like structure?

Huaiyu Zhu hzhu at users.sourceforge.net
Fri Oct 6 12:51:51 EDT 2000


[Huaiyu Zhu]

>> > I need something like a fifo, inplemented in a fixed length list...
>> > an IndexError is raised if the tail gets
>> > too close to the head.

Hi, everyone,

Thanks for all these good ideas. 

[Christian Tismer]

>Hmm, why don't you really use a fixed length list, maintain
>two rotating pointers, and check that they behave well?

Yes, that's what I had in mind when I posted the query.  The real work is to
make the two pointers behave well, of course.  I'm getting there.

>But if the fixed length implementation is not the main goal,
>but to achieve O(1) behavior, then the attached linked list
>implementation might be helpful. It also allows for
>rotations (only efficient for smal deviations).

The fixed length requirement is meant to limit its growth and raise error
when it's full, at that time several different actions might be taken. The
rotation requirement is so that it's light weight even if it's large.

Huaiyu



More information about the Python-list mailing list