Giter VIP home page Giter VIP logo

learnstl's Introduction

从零开始构建自己的标准库

STL庞大而且复杂,很多内容从boost库吸收而来。认识这个庞然大物,非常不容易。

一开始,我们从远处眺望这座STL大山,感觉高不可攀。然而我们的目标是爬上这座山,心中始终有一个信念:九层之台,起于垒土;千里之行,始于足下,

从最简单的cout,到vector,到iterator,到transform,……,我们翻过一座座山峦,不断向高峰进发,志在必得!

最后,站在最高处,回顾之前的点点滴滴,感慨万千。

用了几年,驾轻就熟,于是一番造轮子就开始了 :)

不断造轮子,一方面对先前的知识进行巩固、查漏补缺,另一方面锻炼自己的编程能力,更有甚者,让别人也高兴地用上了自己造的轮子。

目录

走近STL

STL的内容很多,有:

  • containers
  • iterators
  • allocator
  • adapter
  • algorithm
  • functor
  • ……

我学习任何代码,都是在源代码基础上,从零开始慢慢添加代码,思考为什么这样写。这里有大学问——首先要添加什么代码?所以需要对源码结构进行剖析,先添加最核心的代码,然后补充细枝末节;在整个过程中,debug的时间占了90%,但这恰恰最本质地揭示了自己一步步掌握了代码书写技巧和相关概念。倘若只是死板地读源码,那就是盲人摸象,从未走入代码的心,自然学不到东西。

学习顺序

这个轮子是有难度的,好在有许多优秀代码可以参考。

我们从零开始,手写属于自己的STL库,手写属于自己的注释(hey,这是关键哈哈),手写属于自己的细节(我想怎么改就怎么改)。

暂时想到的书写顺序有:

  1. 建立自己的type
  2. 向量vector,常用操作
  3. 迭代器
  4. 仿函数,各种指针的包装,智能指针
  5. 字符串string,常用操作,其实这属于对vector的实际应用,暂时不处理UTF8
  6. 流及包装
  7. typelists(参考自C++设计新思维)
  8. LINQ
  9. 内存池,GC垃圾收集
  10. 其他数据结构
  11. 排序算法
  12. 查找算法
  13. 正则表达式
  14. 反射与注解
  15. XML与JSON的解析
  16. Win32的GUI封装(DirectUI)
  17. 对多线程的封装,包括同步与互斥对象
  18. 对socket的封装
  19. 应用:多人游戏(是不是想太多?)

理想很丰满 :) 任务很艰巨~ 估计没个几年搞不定哈,不过人不能总在舒适区。路漫漫,朝着目标前进吧~

learnstl's People

Contributors

bajdcc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  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.