Code Monkey home page Code Monkey logo

merge2lists's Introduction

##Merge2Lists的功能 将两个list合并为一个集合,并且需要去掉重复元素。

使用不同集合的API来处理效率也差异很大。

##合并的效率?

  • List集合API的使用
    • 1W条数据,只有一个元素重复,去重合并使用的时间为[987]ms,size数为19999;
    • 10W条数据,只有一个元素重复,去重合并使用的时间为[103817]ms,size数为199999;
  • Set集合API的使用
    • 1W条数据,只有一个元素重复,去重合并使用的时间为[11]ms,size数为19999;
    • 10W条数据,只有一个元素重复,去重合并使用的时间为[145]ms,size数为199999;

##得出的结论

  • List集合在处理removeAll时需要进行迭代遍历,每一个元素都要调用contains方法来过滤重复元素,addAll方法则是通过拷贝的方式进行处理的;
  • Set集合只需要调用addAll方法时,将添加的元素作为HashMap中的key来判读是否已经存在重复元素;
  • 在处理去重合并时,从测试结果来看,使用set集合效率较高。

merge2lists's People

Contributors

xjdhanyu avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.