MCPcopy Index your code
hub / github.com/RustPython/RustPython / move_to_end

Method move_to_end

Lib/collections/__init__.py:195–218  ·  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

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

Callers 11

_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
builtin_dict.pyFile · 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