MCPcopy Index your code
hub / github.com/webpy/webpy / requeue

Function requeue

web/utils.py:832–843  ·  view source on GitHub ↗

Returns the element at index after moving it to the beginning of the queue. >>> x = [1, 2, 3, 4] >>> requeue(x) 4 >>> x [4, 1, 2, 3]

(queue, index=-1)

Source from the content-addressed store, hash-verified

830
831
832def requeue(queue, index=-1):
833 """Returns the element at index after moving it to the beginning of the queue.
834
835 >>> x = [1, 2, 3, 4]
836 >>> requeue(x)
837 4
838 >>> x
839 [4, 1, 2, 3]
840 """
841 x = queue.pop(index)
842 queue.insert(0, x)
843 return x
844
845
846def restack(stack, index=0):

Callers

nothing calls this directly

Calls 2

popMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected