第1章容器第1条:慎重选择容器类型。标准STL序列容器:vector、string、deque和list。标准STL关联容器:set、multiset、map和multimap。非标准序列容器slist和rope。slist是一个单向链表,rope本质上是一“重型”string。非标准的关联容器ha...
分类:
编程语言 时间:
2014-05-16 07:50:48
阅读次数:
390
色彩及图像基础(二)学习时间:2014.04.30学到了……1. 图形分为矢量图和位图。 2.
矢量图(vector - based image),是用一系列计算机指令来描述和记录一幅图,这幅图可分解为一系列子图如点、线、面等。 3.
位图(bit-mapped image),是用像素点来描述或映射...
分类:
其他好文 时间:
2014-05-16 06:54:25
阅读次数:
346
没什么多说的。栈:后进先出,LIFO队列:先进先出,
FIFO讲了递归时用到栈,和栈的顺序表示。队列讲了链式表示和循环队列(顺序表示)。实际上都可以用链式和顺序表示,看情况选吧。里面的例题都还挺不错的,自己做了一遍,都是按照书上的结构来的,现在才知道C++STL里都实现了这些功能了,直接调用就成.....
分类:
其他好文 时间:
2014-05-16 06:18:38
阅读次数:
215
题意:给定一棵二叉树,返回按层遍历的结果
思路1:bfs,定义一个新的struct,记录指针向节点的指针和每个节点所在的层
复杂度1:时间O(n),空间O(n)
思路2:dfs
递归函数:
void levelOrder(TreeNode *root, int level, vector<vector >&result)
表示把根为root的树按层存放在result中,其中level表示当前的层数
复杂度2:时间O(n),空间O(n)
相关题目:...
分类:
其他好文 时间:
2014-05-15 14:46:06
阅读次数:
355
快速排序最坏情况下时间复杂度是O(n*n),但是它平均时间复杂度是O(N*logn),并且常数因子很小,可实现就地排序,所以被作为内排序的常用排序方法.
#include
using namespace std;
void swap(int &i,int &j)
{
int temp=i;
i=j;
j=temp;
}
int partition(int *vector...
分类:
其他好文 时间:
2014-05-15 06:05:35
阅读次数:
254
为了效率,copy算法可谓无所不用其极,通过分析copy算法能够体会STL的精妙。
首先是三个对外接口:
template // 泛化版本
inline OutputIterator copy(InputIterator first, InputIterator last,
OutputIterator result)
{
...
分类:
其他好文 时间:
2014-05-15 05:50:02
阅读次数:
315
下面是标准库STL中allocator的实现
template
class allocator
: public _Allocator_base
{ // generic allocator for objects of class _Ty
public:
typedef allocator other;
typedef _Allocator_base _Mybase;
t...
分类:
其他好文 时间:
2014-05-15 05:05:57
阅读次数:
385
题目一:
Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s.
For example, given s = "aab",
Return
[
...
分类:
其他好文 时间:
2014-05-14 15:10:01
阅读次数:
293
在学习Stl的过程中,经常看到->符号的重载,但一直不太明白。
今天做了一个小测试,来看看如果调用它。 以list的迭代器为例,在 pointer operator->() const { return
&(operator*());}中加入 cout str_list; str_list.push...
分类:
其他好文 时间:
2014-05-14 10:32:52
阅读次数:
221
一、介绍
1、STL是C++的一部分,做到了数据结构和算法的分离,具有高度的可重用性、高性能、高度的可移植性、跨平台的优点。
2、字符串string的使用方法:全面介绍了string类的构造、赋值、连接、比较、子串、查找、插入、删除、替换、wstring和统一编码等方面。 STL
简介:分为三类:c...
分类:
其他好文 时间:
2014-05-14 09:05:40
阅读次数:
374