码迷,mamicode.com
首页 >  
搜索关键字:STL    ( 6205个结果
C++运算符重载的妙用
运算符重载(Operator overloading)是C++重要特性之一,本文通过列举标准库中的运算符重载实例,展示运算符重载在C++里的妙用。具体包括重载operator<>支持cin,cout输入输出;重载operator[],实现下标运算;重载operator+=实现元素追加;重载operator()实现函数调用。...
分类:编程语言   时间:2014-09-18 00:48:53    阅读次数:261
统计电影票房排名前10的电影并存入另一个文件
今天看到一个笔试题,是这样的:给定一个文件(m.dat),里面保存了各个电影票房统计,要求写程序统计票房排名前10的电影,并把统计结果存入另一个文件。自己试着用C++实现一下,代码分享如下:(linux下gcc 编译) gcc编译,执行时要传入两个命令行参数,比如:./a.out m.dat li.dat (m.dat为源票房文件,li.dat 为存放前10的文件)...
分类:其他好文   时间:2014-09-17 23:25:32    阅读次数:404
STL algorithm算法make_heap和sort_heap(32)
make_heap原型: std::make_heap default (1) template void make_heap (RandomAccessIterator first, RandomAccessIterator last); custom (2) template void make_heap (Rando...
分类:其他好文   时间:2014-09-17 18:43:42    阅读次数:241
哈希容器的使用
stl的容器库非常强大,但是为了要兼容各种元素类型,采用了模板进行泛化,这样的好处就是使用非常的方便,但是编译器会对使用到的每种类型都进行一遍实例化,用的类型太多的话不仅影响编译速度而且生成的可执行文...
分类:其他好文   时间:2014-09-17 17:01:42    阅读次数:179
STL各个数据结构特点
STL容器特征总结2011-11-09 11:10:50|分类:STL|举报|字号订阅STL中顺序容器类和关联式容器类的主要特征如下:(1)Vector1、内部数据结构:连续存储,例如数组。2、随机访问每个元素,所需要的时间为常量。3、在末尾增加或删除元素所需要时间与元素数目无关,在中间或开头增加或...
分类:其他好文   时间:2014-09-17 15:03:22    阅读次数:319
STL algorithm算法lexicographical_compare(30)
lexicographical_compare原型: std::lexicographical_compare default (1) template bool lexicographical_compare (InputIterator1 first1, InputIterator1 last1, ...
分类:其他好文   时间:2014-09-17 12:13:52    阅读次数:226
STL algorithm算法lower_bound和upper_bound(31)
lower_bound原型: function template std::lower_bound default (1) template ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, ...
分类:其他好文   时间:2014-09-17 12:09:32    阅读次数:235
STL sort
STL的sort()算法,数据量大时采用Quick Sort,分段递归排序,一旦分段后的数据量小于某个门槛,为避免Quick Sort的递归调用带来过大的额外负荷,就改用Insertion Sort。如果递归层次过深,还会改用Heap Sort。本文先分别介绍这个三个Sort,再整合分析STL so...
分类:其他好文   时间:2014-09-17 11:45:12    阅读次数:235
STL algorithm算法is_permutation(27)
is_permutation原型: std::is_permutation equality (1) template bool is_permutation (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2...
分类:其他好文   时间:2014-09-17 10:19:02    阅读次数:433
STL algorithm算法is_sorted和is_sorted_until(28)
is_sort的原型: ::is_sorted default (1) template bool is_sorted (ForwardIterator first, ForwardIterator last); custom (2) template bool is_sorted (ForwardIterator fir...
分类:其他好文   时间:2014-09-17 10:17:32    阅读次数:220
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!