mirror of
https://github.com/samsonjs/CacheCreek.git
synced 2026-03-25 09:05:53 +00:00
fix node removal
This commit is contained in:
parent
fe4dc9a69a
commit
45538b940c
2 changed files with 6 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue