mirror of
https://github.com/donnemartin/system-design-primer.git
synced 2025-12-17 10:28:57 +03:00
Convert all .py files to be valid Python
`raise NotImplementedError('Please replace this line with your code...')` signals to the user where they need to put their code.
This approach enables the codebase to be tested with lint tools like flake8, pyflakes, pylint, etc.
This commit is contained in:
@@ -11,9 +11,14 @@ class LinkedList(object):
|
||||
self.head = None
|
||||
self.tail = None
|
||||
|
||||
def move_to_front(self, node): # ...
|
||||
def append_to_front(self, node): # ...
|
||||
def remove_from_tail(self): # ...
|
||||
def move_to_front(self, node):
|
||||
pass
|
||||
|
||||
def append_to_front(self, node):
|
||||
pass
|
||||
|
||||
def remove_from_tail(self):
|
||||
pass
|
||||
|
||||
|
||||
class Cache(object):
|
||||
@@ -26,7 +31,7 @@ class Cache(object):
|
||||
|
||||
def get(self, query)
|
||||
"""Get the stored query result from the cache.
|
||||
|
||||
|
||||
Accessing a node updates its position to the front of the LRU list.
|
||||
"""
|
||||
node = self.lookup[query]
|
||||
@@ -37,7 +42,7 @@ class Cache(object):
|
||||
|
||||
def set(self, results, query):
|
||||
"""Set the result for the given query key in the cache.
|
||||
|
||||
|
||||
When updating an entry, updates its position to the front of the LRU list.
|
||||
If the entry is new and the cache is at capacity, removes the oldest entry
|
||||
before the new entry is added.
|
||||
@@ -58,4 +63,4 @@ class Cache(object):
|
||||
# Add the new key and value
|
||||
new_node = Node(results)
|
||||
self.linked_list.append_to_front(new_node)
|
||||
self.lookup[query] = new_node
|
||||
self.lookup[query] = new_node
|
||||
|
||||
Reference in New Issue
Block a user