Last active
January 20, 2021 02:59
-
-
Save RinniSwift/82949dccc6092f42a544c9aedf6bee63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LRUCache<T: Hashable, U> { | |
// ... | |
/// Returns the element at the specified key. Nil if it doesn't exist. | |
func retrieveObject(at key: T) -> U? { | |
guard let existingNode = dictionary[key] else { | |
return nil | |
} | |
linkedList.moveToHead(node: existingNode) | |
return existingNode.payload.value | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment