import UIKit class Cat {} func f1() -> ObjectIdentifier { let cat = Cat() return ObjectIdentifier(cat) } func test1() { var a = Set<ObjectIdentifier>() for _ in 0..<10000 { let id = f1() if a.contains(id) { print("conflict") } a.insert(id) } } test1()