我有一個List<Pair<String, String>>
我想從Collection
複製數據。獲取集合元素的最快方法是什麼?
什麼是讀取收藏並將其添加到列表的最佳方式?
List<Pair<String, String>> identityMemoPairs = new LinkedList<Pair<String, String>>();
Collection result = handler.getResult();
while(result.iterator().hasNext()){
IdentityM im =(IdentityM) result.iterator().next();
identityMemoPairs.add(Pair.of(im.identity,im.memo));
}
嗯,我會說最好的方法是......讀取集合並將轉換後的值添加到列表中。沒有更多。 :) - 嚴重的是,這有什麼問題? – Thomas 2012-02-01 15:47:00
檢查http://stackoverflow.com/questions/322715/when-to-use-linkedlist-over-arraylist以瞭解List實現的性能。迭代時,沒有區別。 – jalopaba 2012-02-01 15:54:11
獲取元素需要很長時間。 – michdraft 2012-02-01 15:57:28