Returns - None Input - str ---------- - Adds the current url to the DLL - Sets both the next and previous values - Cleans up forward history to prevent memory leaks - Resets forward count and increments back count
(self, url: str)
| 34 | self._forward_count = 0 |
| 35 | |
| 36 | def visit(self, url: str) -> None: |
| 37 | """ |
| 38 | Returns - None |
| 39 | Input - str |
| 40 | ---------- |
| 41 | - Adds the current url to the DLL |
| 42 | - Sets both the next and previous values |
| 43 | - Cleans up forward history to prevent memory leaks |
| 44 | - Resets forward count and increments back count |
| 45 | """ |
| 46 | # Clear forward history to prevent memory leaks |
| 47 | self._curr.nxt = None |
| 48 | self._forward_count = 0 |
| 49 | |
| 50 | # Create and link new node |
| 51 | url_node = DLL(url) |
| 52 | self._curr.nxt = url_node |
| 53 | url_node.prev = self._curr |
| 54 | |
| 55 | # Update current node and counts |
| 56 | self._curr = url_node |
| 57 | self._back_count += 1 |
| 58 | |
| 59 | def back(self, steps: int) -> str: |
| 60 | """ |