Robocode的线程与执行次序
2008-01-05 10:37:51 来源:WEB开发网核心提示:Here are two methods that allow you to remove duplicates in an ArrayList. removeDuplicate does not maintain the order where as removeDuplicateWithOrder maintain
Here are two methods that allow you to remove duplicates in an ArrayList. removeDuplicate does not maintain the order where as removeDuplicateWithOrder maintains the order with some performance overhead.
1.The removeDuplicate Method:
/** List order not maintained **/
public static void removeDuplicate(ArrayList arlList)
{
HashSet h = new HashSet(arlList);
arlList.clear();
arlList.addAll(h);
}
2.The removeDuplicateWithOrder Method:
/** List order maintained **/
public static void removeDuplicateWithOrder(ArrayList arlList)
{
Set set = new HashSet();
List newList = new ArrayList();
for (Iterator iter = arlList.iterator(); iter.hasNext(); )
{
Object element = iter.next();
if (set.add(element)) newList.add(element);
}
arlList.clear();
arlList.addAll(newList);
}
- ››执行存储过程ORA-01031: insufficient privileges...
- ››执行SQLServer 2005 In-place升级
- ››执行SQL2000 Side-by-side升级
- ››Robocode基本原理之坐标锁定
- ››Robocode 高手的秘诀: 因数避墙法(factored wall...
- ››线程状态图
- ››执行SQL2005升级分离附加
- ››执行SQL2005升级备份还原
- ››执行SQLServer2005In-place升级
- ››执行SQL2000Side-by-side升级
- ››执行DB2的命令有哪些方式
- ››线程基础---wait(),notify的应用一例
赞助商链接