the philosophy behind of the design of the STL
The concept of STL is based on a separation of data and operations. The data is managed by container classes, and the operations are defined by configurable algorithms. Iterators are the glue between these two components and they let any algorithm interact with any container.

//violate using the iterator as the glue between the containers and the algorithm
template<T>
Print(List<T> & container)
{
for(T item: container)
{
//...
}
}
//correct
template<T>
Print(iterator<T> begin, iterator<T> end)
{
for(;begin < end && begin != end; begin ++)
{
//...
}
}
- The STL concept contradicts the original idea of object-oriented programming: the STL serarates data and algorithms rather than combining them. While you can combine every kinds of container with ever kind of algorithm, so the result is a very flexible but still rather small framework.
- The particular implementation of any container is not defined by the C++ standard library. However, the behavior and complexity secified by the standard do not leave much room for variation.
- The STL containers provide only those special member functions that in general have "good" performance, where "good" normal means constant or logarithmic complexity. e.g., a direct element access by using operator [] is not provided for lists. This is because lists don't provide random access, and so an operator [] would have bad performance. Which is also most like why there is no resize() for array.
the philosophy behind of the design of the STL的更多相关文章
- Range-Based for Loops
for ( decl : coll ) { statement } where decl is the declaration of each element of the passed collec ...
- bullet HashMap 内存紧密的哈希表
last modified time:2014-11-9 14:07:00 bullet 是一款开源物理引擎,它提供了碰撞检測.重力模拟等功能,非常多3D游戏.3D设计软件(如3D Mark)使用它作 ...
- Effective STL 学习笔记: Thread Safety and STL Container
Table of Contents 1. STL, Thread and SGI 2. STL and Lock 2.1. RAII 2.2. Use Lock in STL 1 STL, Threa ...
- spring ref &history&design philosophy
Spring Framework Overview Spring是开发java application的通用框架,分为多个模块(modules),核心是core container,包括configu ...
- Spring history&Design Philosophy 简单介绍~
SPRING框架的介绍和历史 Spring Framework是一个开源Java应用程序框架,最初是基于依赖注入(DI)和控制反转(IoC)的原理开发的. Spring Framework已经成长为控 ...
- spring ref history Design philosophy
一.前言 Spring 框架可以说是 Java 开发人员使用的最流行的应用程序开发框架之一.它目前由大量提供一系列服务的模块组成.包括模块容器,为构建横切关注点提供支持的面向切面编程(AOP),安全框 ...
- spring history &design Philosophy
Spring简介 Spring是一个开源框架,它由Rod Johnson创建.它是为了解决企业应用开发的复杂性而创建的.Spring使用基本的JavaBean来完成以前只可能由EJB完成的事情.然而, ...
- design philosophy
- A Proof of Stake Design Philosophy - PoS权益证明设计理念
之前在EthFans上看到了关于PoS(权益证明)的相关文章(原文链接),本着学习的态度,对这篇文章进行了翻译.第一次翻译关于区块链的文章,有些单词及句子的措辞还不是很准确,如果发现有翻译的不恰当的地 ...
随机推荐
- CodeForces 686A-Free Ice Cream
题目: 儿童排队领冰激凌,给你两个数n,x分别代表接下来有n行与初始的冰激淋数:接下来n行,每行有一个字符('+'or‘-’),还有一个整数d,+d表示新增的冰激 凌数(由搬运工搬运到此),-d表示儿 ...
- The data is said to include information from networks
The data is said to include information from networks as well as from individual computers and smart ...
- PostgreSQL的9.4已经发布(译)
http://www.postgresql.org/about/news/1557/ 2014年12月18日,PostgreSQL全球开发小组发布PostgreSQL9.4,PostgresQL是世界 ...
- PKU 1002解题总结
闲来无事,研究了一下PKU1002的题目,大意就是把含有字母的电话号码,转换为数字,然后再计算每个电话号码出现的次数,输出.本来蛮简单的一道题,结果折腾了好久,主要也是自己的水平太菜了,先是直接用字符 ...
- UE4 编译后 不能正常使用Open Level 打开关卡解决方案:Open Level Blueprint Node not workin
配置DefaultEditor.ini 文件 [AllMaps] +Map=/关卡文件路径 参考文献: https://answers.unrealengine.com/questions/141 ...
- [Java Basics] Reflection
For every type of object, the Java virtual machine instantiates an immutable instance of java.lang.C ...
- error CS0103: 当前上下文中不存在名称“ViewBag”
error CS0103: 当前上下文中不存在名称“ViewBag” View文件夹下缺少web.config文件
- 在maven项目中解决第三方jar包依赖的问题
在maven项目中,对于那些在maven仓库中不存在的第三方jar,依赖解决通常有如下解决方法: 方法1:直接将jar包拷贝到项目指定目录下,然后在pom文件中指定依赖类型为system,如: < ...
- bootstrap-10
实现原理: 通过定义容器大小,平分12份(也有分为24份或32份,但12份是最常见的),在调整内外边距,最后结合媒体查询,就制作除了强大的响应式网格系统. 工作原理: 1.数据行(.row)必须包含在 ...
- Struts2 Action中的方法命名不要以get开头
偶然发现,在调用一个action中的某个方法时,会自动调用另一个无关的方法,找了好久,最后发现是方法命名的问题,方法命名以get开头,action会自动调用!所以,以后再写action中的方法时尽量不 ...