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

Method remove

other/lfu_cache.py:145–161  ·  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

143 previous_node.prev = node
144
145 def remove(
146 self, node: DoubleLinkedListNode[T, U]
147 ) -> DoubleLinkedListNode[T, U] | None:
148 """
149 Removes and returns the given node from the list
150
151 Returns None if node.prev or node.next is None
152 """
153
154 if node.prev is None or node.next is None:
155 return None
156
157 node.prev.next = node.next
158 node.next.prev = node.prev
159 node.prev = None
160 node.next = None
161 return node
162
163
164class LFUCache[T, U]:

Callers 2

getMethod · 0.45
putMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected