Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60754
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: how to implement a queue-like container with sort function |
| Date | 2013-11-28 21:31 -0500 |
| References | <b5e67d65-76a4-4a1a-87b4-70402c9bf865@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3392.1385692320.18130.python-list@python.org> (permalink) |
On 11/28/2013 8:54 PM, 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 For single thread use, subclass list, add a new .put method that checks the list size and either does self.append or self.sort(); process(list). For multiple threads, you need the queue module, which has extra features (and baggage). A PriorityQueue yields items in sorted order. Subclass it and override .put to either call the original .put or start a process thread. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-11-28 17:54 -0800
Re: how to implement a queue-like container with sort function Chris Angelico <rosuav@gmail.com> - 2013-11-29 13:03 +1100
Re: how to implement a queue-like container with sort function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-29 03:32 +0000
Re: how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-11-28 18:04 -0800
Re: how to implement a queue-like container with sort function Chris Angelico <rosuav@gmail.com> - 2013-11-29 13:06 +1100
Re: how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-11-28 18:32 -0800
Re: how to implement a queue-like container with sort function Cameron Simpson <cs@zip.com.au> - 2013-11-29 17:19 +1100
Re: how to implement a queue-like container with sort function MRAB <python@mrabarnett.plus.com> - 2013-11-29 02:23 +0000
Re: how to implement a queue-like container with sort function Terry Reedy <tjreedy@udel.edu> - 2013-11-28 21:31 -0500
Re: how to implement a queue-like container with sort function Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-11-29 17:53 +1300
Re: how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-11-29 04:33 -0800
Re: how to implement a queue-like container with sort function Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-29 14:57 +0000
Re: how to implement a queue-like container with sort function iMath <redstone-cold@163.com> - 2013-12-02 03:41 -0800
Re: how to implement a queue-like container with sort function Ned Batchelder <ned@nedbatchelder.com> - 2013-12-02 06:58 -0500
Re: how to implement a queue-like container with sort function Chris Angelico <rosuav@gmail.com> - 2013-12-02 23:04 +1100
Re: how to implement a queue-like container with sort function Ned Batchelder <ned@nedbatchelder.com> - 2013-12-02 07:26 -0500
csiph-web