Skip to content

Commit 61e0d3d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 106bf5f commit 61e0d3d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

data_structures/lru_cache.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@
22
An implementation of a Least Recently Used (LRU) Cache.
33
... (the rest of the docstring is the same)
44
"""
5+
56
from __future__ import annotations
67
from typing import Optional
78

9+
810
class Node:
911
"""A node in the doubly linked list."""
12+
1013
def __init__(self, key: int, val: int) -> None:
1114
self.key, self.val = key, val
1215
self.prev: Optional[Node] = None
1316
self.next: Optional[Node] = None
1417

18+
1519
class LRUCache:
1620
"""
1721
A Least Recently Used (LRU) Cache data structure.
1822
... (the doctests are the same)
1923
"""
24+
2025
def __init__(self, capacity: int) -> None:
2126
if capacity <= 0:
2227
raise ValueError("Capacity must be a positive integer.")
@@ -67,6 +72,8 @@ def put(self, key: int, value: int) -> None:
6772
self._remove(lru)
6873
del self.cache[lru.key]
6974

75+
7076
if __name__ == "__main__":
7177
import doctest
72-
doctest.testmod()
78+
79+
doctest.testmod()

0 commit comments

Comments
 (0)