deduplicate

public static List<T> deduplicate<T>(List<T> list, Deduplicate<T> 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


public static List<T> deduplicate<T>(List<T> list)

Simplifies the overloaded method, using the toString of generic T to generate the key