Constructor
new SelfCanonMap()
Example
Take this data type Duck: { name: string, featherCount: number ).
Ducks are identified by their name, so we can use a SelfCanonMap both to store the canonical version of a Duck, and to look up a Duck knowing its name only:
const duckMap = new SelfCanonMap([{ name: 'Rodney', featherCount: 13217 }, { name: 'Ellis', featherCount: 11992 }], ({name}) => name)
duckMap.get({name: 'Ellis'}) // { name: 'Ellis', featherCount: 11992 }
Methods
add(val)
Adds the value to the SelfCanonMap. If any value collides with its canonization, that value will be overwritten.
Parameters:
Name | Type | Description |
---|---|---|
val |
T | The value to set. |
Returns:
the SelfCanonMap object.
fill(vals)
Adds values to the SelfCanonMap. If any value collides with its canonization, that value will be overwritten.
Parameters:
Name | Type | Description |
---|---|---|
vals |
T | The values to add. |
Returns:
the SelfCanonMap object.