1
Swift Language Fundamentals / Memory Management
1. Скомпилируется ли код? И если да, то почему?
struct A {
let a: A // value copy
}
class B {
let b: B / ///? by ref reference
init(b: B) {
self.b = b
}
}2
Concurrency / Data Structures (LRU Cache)
2. Задача: Проанализировать и доработать реализацию ImageCache (LRU cache) с учетом многопоточности и корректности работы.
class ImageCache {
private var cache: [Int:String]
private let queue = DispatchQueue(label: "myCache", attributes: .concurrent)
private var capacity: Int
private let order: [Int] = []
init(capacity: Int) {
self.capacity = capacity
}
func get(_ key: Int) -> String? {
queue.sync {…