A bi-directional dictionary/map for the Swift programming language.
Usage:
var biDict = BiDictionary<String, String>()
biDict[key: "foo"] = "bar"
let value = biDict[key: "foo"]
let key = biDict[value: "bar"]
Because the mapping is one-to-one in both directions, assigning a value that
another key already holds displaces that key — and the same the other way round.
Last write wins, as it does with Dictionary:
biDict[key: "foo"] = "bar"
biDict[key: "baz"] = "bar" // "foo" no longer has a value; "bar" now belongs to "baz"
biDict[key: "baz"] = nil // removes the pairing from both directions
If you need the strict behaviour instead — refuse a write that would displace an existing pairing — look the value up first and branch on the result.
