MCPcopy Index your code
hub / github.com/python/cpython / move_to_end

Method move_to_end

Lib/collections/__init__.py:194–217  ·  view source on GitHub ↗

Move an existing element to the end (or beginning if last is false). Raise KeyError if the element does not exist.

(self, key, last=True)

Source from the content-addressed store, hash-verified

192 return key, value
193
194 def move_to_end(self, key, last=True):
195 '''Move an existing element to the end (or beginning if last is false).
196
197 Raise KeyError if the element does not exist.
198 '''
199 link = self.__map[key]
200 link_prev = link.prev
201 link_next = link.next
202 soft_link = link_next.prev
203 link_prev.next = link_next
204 link_next.prev = link_prev
205 root = self.__root
206 if last:
207 last = root.prev
208 link.prev = last
209 link.next = root
210 root.prev = soft_link
211 last.next = link
212 else:
213 first = root.next
214 link.prev = root
215 link.next = first
216 first.prev = soft_link
217 root.next = link
218
219 def __sizeof__(self):
220 sizeof = _sys.getsizeof

Callers 10

_signature_get_partialFunction · 0.95
test_namespace_orderMethod · 0.95
test_dict_copy_orderMethod · 0.95
test_kwargs_orderMethod · 0.95
test_ordereddictMethod · 0.95
test_move_to_endMethod · 0.80
__getitem__Method · 0.80
__setitem__Method · 0.80

Calls

no outgoing calls

Tested by 9

test_namespace_orderMethod · 0.76
test_dict_copy_orderMethod · 0.76
test_kwargs_orderMethod · 0.76
test_ordereddictMethod · 0.76
test_move_to_endMethod · 0.64
__getitem__Method · 0.64
__setitem__Method · 0.64