Skip to content

Commit 1f283d1

Browse files
authored
Update lfu_cache.py
1 parent f03ac54 commit 1f283d1

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

other/lfu_cache.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
from __future__ import annotations
22

33
from collections.abc import Callable
4-
from typing import Generic, TypeVar
54

6-
T = TypeVar("T")
7-
U = TypeVar("U")
85

9-
10-
class DoubleLinkedListNode(Generic[T, U]):
6+
class DoubleLinkedListNode[T, U]:
117
"""
128
Double Linked List Node built specifically for LFU Cache
139
@@ -30,7 +26,7 @@ def __repr__(self) -> str:
3026
)
3127

3228

33-
class DoubleLinkedList(Generic[T, U]):
29+
class DoubleLinkedList[T, U]:
3430
"""
3531
Double Linked List built specifically for LFU Cache
3632
@@ -76,7 +72,6 @@ class DoubleLinkedList(Generic[T, U]):
7672
Node: key: 2, val: 20, freq: 1, has next: True, has prev: True,
7773
Node: key: None, val: None, freq: 0, has next: False, has prev: True
7874
79-
8075
>>> # Attempt to remove node not on list
8176
>>> removed_node = dll.remove(first_node)
8277
>>> removed_node is None
@@ -159,9 +154,7 @@ def remove(
159154
node.prev = None
160155
node.next = None
161156
return node
162-
163-
164-
class LFUCache(Generic[T, U]):
157+
class LFUCache[T, U]:
165158
"""
166159
LFU Cache to store a given capacity of data. Can be used as a stand-alone object
167160
or as a function decorator.

0 commit comments

Comments
 (0)