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(权益证明)的相关文章(原文链接),本着学习的态度,对这篇文章进行了翻译.第一次翻译关于区块链的文章,有些单词及句子的措辞还不是很准确,如果发现有翻译的不恰当的地 ...
随机推荐
- 关于VS2013中Win32程序怎么修改图标
首先向资源文件上加上你要添加的资源(把你要添加的图标放在你的工程的下面,然后右击资源文件选中添加资源,然后选择导入你要添加的图标),下面你只要打开你项目的.rc文件要用查看代码形式打开,然后只要把系统 ...
- linux命令:locate
1.命令介绍: locate用来查找文件,它是在系统的数据库中查找,所以速度非常快. 2.命令格式: locate [选项] 模式 ---这里的模式是指正则表达式 3.命令参数: -e ...
- url 传参写法
qianee-web/invite/123 @RequestMapping("/invite/{userId}") public ModelAndView invite(HttpS ...
- sublime 的使用
常见问题: ctrl+`快捷见弹不出console怎么办! 解决方法: 估计适合电脑其他软件的快捷键冲突了,在sublime里面重新设置下快捷键 点击菜单中Preferences下面的Key Bind ...
- 第九课,T语言数组的定义与访问(版本5.0)
数组的定义与访问 数组是一系列数据的集合,可以存储大量数据,通过数组的下标.key,可以实现对数据的快速访问. 为什么要使用数组呢? 如果您有一个项目列表(例如汽车品牌列表),在单个变量中存储这些品牌 ...
- wordpress(二)wordpress环境迁移
迁移wordpress到服务器 本地环境如下 win8.1 appser 服务器环境如下 centos7 lnmp 1.使用phpmyadmin备份本地wordpress站点的数据库 2.备份本地wo ...
- [cyber security][php]pfSense目录遍历漏洞分析
0×00 导言 pfSense是一个基于FreeBSD,专为防火墙和路由器功能定制的开源版本. 在本文中,我们将向大家介绍在pfSense的2.1.3以及更低版本中的CVE-2014-4690漏洞:对 ...
- [原创]cocos2d-x研习录-第二阶 概念类之摄相机类(CCCamera)
在Cocos2D-x中,每个CCNode都拥有一个摄像机类CCCamera.只有通过CCCamera,CCNode才会被渲染出来.当CCNode发生缩放.旋转和位置变化时,都需要覆盖CCCamera, ...
- 大数据——Hadoop集群坏境CentOS安装
前言 前面我们主要分析了搭建Hadoop集群所需要准备的内容和一些提前规划好的项,本篇我们主要来分析如何安装CentOS操作系统,以及一些基础的设置,闲言少叙,我们进入本篇的正题. 技术准备 VMwa ...
- JavaScript 字符串转日期
一.将字符串装换为日期 var date= new Date(Date.parse(strTime.replace(/-/g, "/"))); //转换成Data();