diff --git a/Source/DoublyLinkedList.swift b/Source/DoublyLinkedList.swift index 1bc157a..28a1c1d 100644 --- a/Source/DoublyLinkedList.swift +++ b/Source/DoublyLinkedList.swift @@ -58,18 +58,15 @@ struct DoublyLinkedList { } mutating func remove(node node: Node) { - if let prev = node.prev { - prev.next = node.next - } - else { + if node === head { head = node.next } - if let next = node.next { - next.prev = node.prev - } - else { + if node === tail { tail = node.prev } + + node.prev?.next = node.next + node.next?.prev = node.prev node.next = nil node.prev = nil count -= 1 diff --git a/Source/LRUCache.swift b/Source/LRUCache.swift index a5c99d2..1e58ff4 100644 --- a/Source/LRUCache.swift +++ b/Source/LRUCache.swift @@ -7,7 +7,7 @@ // Modified to use LRU eviction by Sami Samhuri on 2016-08-10. // -import Foundation +import UIKit /// `LRUCache` is an LRU cache that can hold anything, including Swift structs, enums, and values. /// It is designed to work similar to the `NSCache`, but with native Swift support.