可重复排序的Java集合 [英] Sortable Java collection without duplicates
问题描述
我正在寻找可排序(我的意思是排序初始化后和使用Comparator多次)Java类集合没有重复。是否有更纯的解决方案比编写代码不透明,并防止例如一些ArrayList添加另一个对象与已经存在的相同的值?
编辑1:
我应该添加一些关于排序的解释。我需要用不同的比较器(实现的多样性)多次对这组值进行排序。
http://docs.oracle.com/javase/6/docs/api/java/util/Set.html\">设置!常见的实现是 HashSet 和 TreeSet 。后者保留项目在执行 SortedSet 时的顺序。 p>
I am searching for sortable (I mean sorting after initialization and many times using Comparator) Java class collection without duplicates. Is there any more pure solution than writing code which will opaque and prevent for example some ArrayList for adding another object with the same value that already exists?
Edit 1: I should add some explanation about sorting. I need to sort this set of values many times with different comparators (diversity of implementations).
Use a Set! The common implementations are HashSet and TreeSet. The latter preserves the order of items as it implements SortedSet.
这篇关于可重复排序的Java集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!