Message181086
It can be useful to rotate an OrderedDict (for example when managing a circular playlist). I haven't found any efficient way to do so from user code, without poking at the internals.
Actually, I envision three methods:
OrderedDict.rotate(self, n):
rotate n steps to the right (similarly to deque.rotate())
OrderedDict.rotate_at(self, key):
rotate so that the given key ends up in first position
OrderedDict.rotate_after(self, key):
rotate so that the given key ends up in last position
(rotate_at, rotate_after could be merged in a single method with a "last" argument, if deemed more elegant)
Note: another solution to the playlist problem would be to have insert_after() and insert_before() methods. |
|
Date |
User |
Action |
Args |
2013-02-01 16:32:03 | pitrou | set | recipients:
+ pitrou, rhettinger |
2013-02-01 16:32:03 | pitrou | set | messageid: <1359736323.45.0.953309245292.issue17100@psf.upfronthosting.co.za> |
2013-02-01 16:32:03 | pitrou | link | issue17100 messages |
2013-02-01 16:32:02 | pitrou | create | |
|