Probably the most efficient way is ImmutableSet.copyOf(list).asList()
, which eliminates duplicates and preserves iteration order.
(But your implementation with LinkedHashSet
would be nearly as efficient, and wouldn't throw up on nulls, in the unlikely event you actually wanted nulls in your collection.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…