how to implement a queue-like container with sort function

MRAB python at mrabarnett.plus.com
Thu Nov 28 21:23:12 EST 2013


On 29/11/2013 01:54, iMath wrote:
> I want to a fixed length list-like container, it should have a
> sorted()-like function that I can use to sort it,I think there should
> also a function I can use it to detect whether the numbers of items
> in it reaches the length of the container , because if the numbers of
> items in it reaches the length(fixed) of the container,I want to
> process the data in it .Is there a container in Python like this ?If
> not, what base container should be used to implement such container?
>
> the container is similar to queue ,but queue doesn't have a sort
> function
>
This is Python. You don't have to base it on an existing container.

Write a list of the methods it should have. If none of the existing
classes seem suitable as a superclass, then don't bother, just write it
from scratch. You can always use an existing container, such as a list,
as part of its implementation.



More information about the Python-list mailing list