Giter Club home page Giter Club logo

myvector's Introduction

实现vector类模板

  1. 一个基本数组,通过指针指向分配的内存块,一个存数组容量的变量,一个存数组元素个数(长度)的变量
  2. 三大函数:复制构造函数、operator=提供深复制、析构回收数组
  3. resize改变vector长度,reserve改变vector容量,push_back/pop_back增/减元素,size返回长度,empty返回是否空,clear清空,capacity返回容量,
  4. 下标[]操作:访问函数返回常量引用,修改函数返回引用
  5. 内嵌类型:const_iterator和iterator,需要实现operator++(前置后置),==,!=,*(访问/修改)等操作符,受保护的构造函数
  6. 增加begin,end,erase,insert等迭代器操作
  7. 错误检测:包括越界检测,指针未初始化或已到末尾时的++和*,迭代器做erase和insert时是否属于正确的vector

myvector's People

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.