mirror of
https://github.com/samsonjs/CacheCreek.git
synced 2026-04-27 15:07:39 +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) {
|
mutating func remove(node node: Node) {
|
||||||
if let prev = node.prev {
|
if node === head {
|
||||||
prev.next = node.next
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
head = node.next
|
head = node.next
|
||||||
}
|
}
|
||||||
if let next = node.next {
|
if node === tail {
|
||||||
next.prev = node.prev
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tail = node.prev
|
tail = node.prev
|
||||||
}
|
}
|
||||||
|
|
||||||
|
node.prev?.next = node.next
|
||||||
|
node.next?.prev = node.prev
|
||||||
node.next = nil
|
node.next = nil
|
||||||
node.prev = nil
|
node.prev = nil
|
||||||
count -= 1
|
count -= 1
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
// Modified to use LRU eviction by Sami Samhuri on 2016-08-10.
|
// 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.
|
/// `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.
|
/// It is designed to work similar to the `NSCache`, but with native Swift support.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue