Giter VIP home page Giter VIP logo

cpp_study's Introduction

Notes for cpp

  1. Since c++11 the STL has std::array which is a template-based array class, use std::array instead of raw arrays whenever possible.

  2. Something new about iterators:
    begin() and end(): iterator
    cbegin() and cend(): const_iterator
    rbegin() and rend(): reverse_iterator
    crbegin() and crend(): const_reverse_iterator

  3. Whenever you put scope resolution operator in the front of something, that means global scope
    eg. ::toupper()

  4. std::array (c++ 11)
    Fixed size
    Direct element access
    Provides access to the underlying raw array
    Use instead of raw arrays when possible
    All iterators available and do not invalidate

  5. eg: vec.emplace_back("Larry", 18);
    //vec.push_back(Person{"Larry", 18});
    emplace_back is really efficient, no move no copies, it just puts it right where it's supposed to be.

  6. std::back_inserter constructs a back-insert iterator that inserts new elements at the end of the container it applied to.
    It's a special output iterator, awesome and efficient.
    eg. std::copy(vec1.begin(), vec1.end(), std::back_inserter(vec2));

  7. deque: double end queue, dynamic size, not contiguous in memory.
    When adding new elements, it allocates blocks in the memory, as is shown in the picture below:

  8. std::list
    doubly linked list of elements, no direct access, rapid insertion and deletion of element anywhere (const time)

  9. c++11
    std::forward_list
    Compare to list, reverse iterator not available, No size() and back() method.

cpp_study's People

Contributors

nn75 avatar

Watchers

 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.