Skip to content

Commit 762df14

Browse files
committed
docs: fix clear() time complexity from O(1) to O(n)
clear() now iterates through linked list to nullify prev/next pointers, allowing proper garbage collection of nodes.
1 parent 9fbe54c commit 762df14

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

docs/TECHNICAL_DOCUMENTATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ sequenceDiagram
128128
| `delete(key)` | O(1) | O(1) | O(1) | Remove item from cache |
129129
| `has(key)` | O(1) | O(1) | O(1) | Check key existence |
130130
| `peek(key)` | O(1) | O(1) | O(1) | Retrieve value without LRU update |
131-
| `clear()` | O(1) | O(1) | O(1) | Reset all pointers |
131+
| `clear()` | O(n) | O(n) | O(1) | Reset all pointers, nullify node links |
132132
| `evict()` | O(1) | O(1) | O(1) | Remove least recently used item |
133133
| `expiresAt(key)` | O(1) | O(1) | O(1) | Get expiration timestamp |
134134
| `moveToEnd(item)` | O(1) | O(1) | O(1) | Internal: optimize LRU positioning |

0 commit comments

Comments
 (0)