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

Class DoubleLinkedListNode

other/lru_cache.py:10–28  ·  view source on GitHub ↗

Double Linked List Node built specifically for LRU Cache >>> DoubleLinkedListNode(1,1) Node: key: 1, val: 1, has next: False, has prev: False

Source from the content-addressed store, hash-verified

8
9
10class DoubleLinkedListNode[T, U]:
11 """
12 Double Linked List Node built specifically for LRU Cache
13
14 >>> DoubleLinkedListNode(1,1)
15 Node: key: 1, val: 1, has next: False, has prev: False
16 """
17
18 def __init__(self, key: T | None, val: U | None):
19 self.key = key
20 self.val = val
21 self.next: DoubleLinkedListNode[T, U] | None = None
22 self.prev: DoubleLinkedListNode[T, U] | None = None
23
24 def __repr__(self) -> str:
25 return (
26 f"Node: key: {self.key}, val: {self.val}, "
27 f"has next: {bool(self.next)}, has prev: {bool(self.prev)}"
28 )
29
30
31class DoubleLinkedList[T, U]:

Callers 2

__init__Method · 0.70
putMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected