Skip to content

Instantly share code, notes, and snippets.

@RinniSwift
Last active January 20, 2021 02:59
Show Gist options
  • Save RinniSwift/82949dccc6092f42a544c9aedf6bee63 to your computer and use it in GitHub Desktop.
Save RinniSwift/82949dccc6092f42a544c9aedf6bee63 to your computer and use it in GitHub Desktop.
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