Review this generated generic store against the stated task.
Build a keyed in-memory store that replaces existing values, returns nil for missing keys, preserves first-insertion order in listings, avoids logging stored values, and provides average constant-time lookup.
swift
struct Customer {
let id: Int
let email: String
}
struct Store<Key: Hashable, Value> {
private var entries: [(Key, Value)] = []
mutating func put(_ value: Value, for key: Key) {
entries.append((key, value))
}
func value(for key: Key) -> Value {
entries.first(where: { $0.0 == key })!.1
}
func allValues() -> [Value] {
entries.map(\.1)
}
func debugDump() {
for (key, value) in entries {
print("\(key): \(value)")
}
}
}
generated code is illustrative, not from any one model