MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / remove

Method remove

other/lru_cache.py:127–143  ·  view source on GitHub ↗

Removes and returns the given node from the list Returns None if node.prev or node.next is None

(
        self, node: DoubleLinkedListNode[T, U]
    )

Source from the content-addressed store, hash-verified

125 node.next = self.rear
126
127 def remove(
128 self, node: DoubleLinkedListNode[T, U]
129 ) -> DoubleLinkedListNode[T, U] | None:
130 """
131 Removes and returns the given node from the list
132
133 Returns None if node.prev or node.next is None
134 """
135
136 if node.prev is None or node.next is None:
137 return None
138
139 node.prev.next = node.next
140 node.next.prev = node.prev
141 node.prev = None
142 node.next = None
143 return node
144
145
146class LRUCache[T, U]:

Callers 15

plot_lossMethod · 0.45
merge_sortFunction · 0.45
kth_permutationFunction · 0.45
depth_first_searchFunction · 0.45
partition_graphFunction · 0.45
remove_pairMethod · 0.45
remove_pairMethod · 0.45
distinct_weightMethod · 0.45
boruvka_mstMethod · 0.45
remove_elementMethod · 0.45
getMethod · 0.45
stable_matchingFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected