首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

对两个LIST对行比对,罗选

2012-12-27 
对两个LIST对行比对,筛选?对两个LIST对行比对,筛选以下两种方法比对中会发现用情况 ? ? ?(单位 ns)??? ?Co

对两个LIST对行比对,筛选

?

对两个LIST对行比对,筛选

以下两种方法比对中会发现用情况 ? ? ?(单位 ns)

??? ?CollectionUtils ? ?ListUtils

52354 ? ? ? ? ? ? 811485

49659? ? ??790698

?

package com.collection;import java.util.*;import org.apache.commons.collections.CollectionUtils;import org.apache.commons.collections.ListUtils;public class ListFilter {public static void main(String[] args) {List l1 = new ArrayList();List l2 = new ArrayList();l1.add(1);l1.add(2);l1.add(3);l1.add(5);l2.add(4);l2.add(5);Collection s1 = CollectionUtils.union(l1, l2);Long start = System.nanoTime();Collection s2 = CollectionUtils.subtract(l1, l2);System.out.println(System.nanoTime() - start);Long start1 = System.nanoTime();List ls = ListUtils.subtract(l1, l2);System.out.println(System.nanoTime() - start1);Collection s3 = CollectionUtils.intersection(l1, l2);Collection s4 = CollectionUtils.disjunction(l1, l2);System.out.println(s4);System.out.println(s1);System.out.println(s2);System.out.println(s3);}}
?

热点排行