deduplicate
Deduplicates a List.
If a key is duplicated, the existing element will be overwritten by the subsequent element. Time complexity is 2N.
Return
The deduplicated List
Parameters
list
The List before deduplication
deduplicate
The deduplication interface, where the upper layer determines the key for deduplication
Simplifies the overloaded method, using the toString of generic T to generate the key