Giter VIP home page Giter VIP logo

cppprimer_5th_cn's People

Contributors

amytx avatar smzztx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cppprimer_5th_cn's Issues

对练习12.31,《C++ Primer习题集》上给出的答案为vector更优

对练习12.31,《C++ Primer习题集》上给出的答案为vector更优,原文如下:“ 对这个问题而言,vector 更好。因为,虽然vector 不会维护元素值的序,set 会维护关键字的序,但注意到,我们是逐行读取输入文本的,因此每个单词出现的行号是自然按升序加入到容器中的,不必特意用关联容器来保证行号的升序。而从性能角度,set是基于红黑树实现的,插入操作时间复杂性为0(log n) (n为容器中元素数目),而vector的 push back 可达到常量时间。
另外,一个单词在同一行中可能出现多次。set 自然可保证关键字不重复,但对 vector 这也不成为障碍一一每次添加行号前与最后一个行号比较一下即可。总体性能仍然是vector更优。”
链接:
https://blog.csdn.net/shamozhizhoutx/article/details/83056020#comments_23214236

对练习12.31,《C++ Primer习题集》上给出的答案为vector更优

对练习12.31,《C++ Primer习题集》上给出的答案为vector更优,原文如下:“ 对这个问题而言,vector 更好。因为,虽然vector 不会维护元素值的序,set 会维护关键字的序,但注意到,我们是逐行读取输入文本的,因此每个单词出现的行号是自然按升序加入到容器中的,不必特意用关联容器来保证行号的升序。而从性能角度,set是基于红黑树实现的,插入操作时间复杂性为0(log n) (n为容器中元素数目),而vector的 push back 可达到常量时间。
另外,一个单词在同一行中可能出现多次。set 自然可保证关键字不重复,但对 vector 这也不成为障碍一一每次添加行号前与最后一个行号比较一下即可。总体性能仍然是vector更优。”
链接:
https://blog.csdn.net/shamozhizhoutx/article/details/83056020#comments_23214236

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.