码迷,mamicode.com
首页 >  
搜索关键字:仿函数    ( 207个结果
GeekBand_CPP_STL_Architecture&Container
STL六大部件: Containers(容器) Allocators(分配器) Algorithms(算法) Iterators(迭代器) Adapters(适配器) Functors仿函数) STL的主体在于容器,其他五个部件共同实现了容器的各种功能 ...
分类:其他好文   时间:2016-11-21 22:46:44    阅读次数:169
STL源码剖析(仿函数/bind2nd)
仿函数(functors)其实就是重载了operator()的对象。 下面简单先看看它的一个例子: 1 #include <iostream> 2 using namespace std; 3 4 template<typename T> 5 struct m_plus 6 { 7 T operat ...
分类:其他好文   时间:2016-10-31 13:28:28    阅读次数:263
Sublime Text插件之SublimeHighlight
简单来说,SublimeText的SublimeHighlight插件可以将Sublime Text编辑器中的代码样式, 包括缩进,代码高亮等转换为html代码,当在浏览器中查看时,可与Sublime Text别无二致, 在html中需要插入高亮代码时,可考虑之! 安装方法: 1、添加Sublime ...
分类:其他好文   时间:2016-10-23 02:51:25    阅读次数:611
模板参数推导
STL有6大组件,阅读《STL源码剖析》后,对于我来说主要收货为:内存分配器、迭代器、仿函数。特别是迭代器章节收货最多,其中重中之重为traits机制的运用。 traits技法——STL的入门钥匙 首先必须清楚模板的参数推导机制,例如: ...
分类:其他好文   时间:2016-10-20 14:28:42    阅读次数:144
Heap堆
#pragma once#include<iostream>using namespace std;#include<vector>template<class T> //仿函数struct Less{ bool operator()(const T&l, const T&r) //重载括号 { r ...
分类:其他好文   时间:2016-10-11 21:28:09    阅读次数:129
仿函数
一,概述 仿函数(functor),就是使一个类的使用看上去象一个函数。其实现就是类中实现一个operator(),这个类就有了类似函数的行为,就是一个仿函数类了。 有些功能的的代码,会在不同的成员函数中用到,想复用这些代码。 1)公共的函数,可以,这是一个解决方法,不过函数用到的一些变量,就可能成 ...
分类:其他好文   时间:2016-09-07 19:03:36    阅读次数:138
c++map按value排序--将map的pair对保存到vector中,然后写比较仿函数+sort完成排序过程。
map是用来存放<key, value>键值对的数据结构,可以很方便快速的根据key查到相应的value。假如存储学生和其成绩(假定不存在重名,当然可以对重名加以区分),我们用map来进行存储就是个不错的选择。 我们这样定义,map<string, int>,其中学生姓名用string类型,作为Ke ...
分类:编程语言   时间:2016-09-06 23:03:35    阅读次数:329
文件压缩
Heap.h: #pragmaonce #include<vector> #include<assert.h> //仿函数 template<classT> //小堆 structLess { booloperator()(constT&l,constT&r) { returnl<r; } }; template<classT> //大堆 structGreater { booloperator()(constT&..
分类:其他好文   时间:2016-09-04 00:14:19    阅读次数:183
[GeekBand] STL 仿函数入门详解
本文参考文献::GeekBand课堂内容,授课老师:张文杰 :C++ Primer 11 中文版(第五版) page 37 :网络资料: 叶卡同学的部落格 http://www.leavesite.com/ 前言:本文主要通过关联容器set解释下仿函数的实现及工作原理。 一、STL六大组件简介 1、 ...
分类:其他好文   时间:2016-08-29 22:41:56    阅读次数:315
大/小堆:源代码
#pragmaonce #include<vector> #include<assert.h> // //小堆==大堆 //仿函数 // template<classT> structGreater { booloperator()(constT&l,constT&r) { returnl>r; } }; template<classT> structLess { booloperator()(constT&..
分类:其他好文   时间:2016-08-26 23:09:02    阅读次数:201
207条   上一页 1 ... 8 9 10 11 12 ... 21 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!