Skip to content

Commit 2c17e86

Browse files
authored
Update lfu_cache.py
1 parent 9d16049 commit 2c17e86

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

other/lfu_cache.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
U = TypeVar("U")
88

99

10-
class DoubleLinkedListNode(Generic[T, U]):
10+
class DoubleLinkedListNode[T, U]:
1111
"""
1212
Double Linked List Node built specifically for LFU Cache
1313
@@ -30,7 +30,7 @@ def __repr__(self) -> str:
3030
)
3131

3232

33-
class DoubleLinkedList(Generic[T, U]):
33+
class DoubleLinkedList[T, U]:
3434
"""
3535
Double Linked List built specifically for LFU Cache
3636
@@ -96,7 +96,6 @@ class DoubleLinkedList(Generic[T, U]):
9696
9797
9898
"""
99-
10099
def __init__(self) -> None:
101100
self.head: DoubleLinkedListNode[T, U] = DoubleLinkedListNode(None, None)
102101
self.rear: DoubleLinkedListNode[T, U] = DoubleLinkedListNode(None, None)
@@ -159,9 +158,7 @@ def remove(
159158
node.prev = None
160159
node.next = None
161160
return node
162-
163-
164-
class LFUCache(Generic[T, U]):
161+
class LFUCache[T, U]:
165162
"""
166163
LFU Cache to store a given capacity of data. Can be used as a stand-alone object
167164
or as a function decorator.
@@ -276,7 +273,6 @@ def put(self, key: T, value: U) -> None:
276273
assert node is not None # node guaranteed to be in list
277274
node.val = value
278275
self.list.add(node)
279-
280276
@classmethod
281277
def decorator(
282278
cls: type[LFUCache[T, U]], size: int = 128

0 commit comments

Comments
 (0)