Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the ...
分类:
其他好文 时间:
2014-07-16 23:07:09
阅读次数:
196
http://eli.thegreenplace.net/2010/01/22/weighted-random-generation-in-python/类似俄罗斯轮盘赌
分类:
其他好文 时间:
2014-07-12 08:33:57
阅读次数:
177
Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the ...
分类:
其他好文 时间:
2014-07-12 08:24:00
阅读次数:
258
Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the ...
分类:
其他好文 时间:
2014-07-12 08:23:16
阅读次数:
231
Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the ...
分类:
其他好文 时间:
2014-07-12 08:22:39
阅读次数:
181
Debug (调试版) 汇编和 Release (发行版)
汇编的认识
调试版基本不优化,发行版则一般都优化到极致。
Windows驱动开发中,一般称为Check版本和Free版本
我们暂时只研究Debug(调试版)
for循环C实现:
int func(int a,int b)
{
int c=a+b;
int i;
for(i=0;i<50;i++){
...
分类:
编程语言 时间:
2014-07-10 23:42:14
阅读次数:
284
旧式转型
(T) expression 或 T (expression)
新式转型
const_cast(expression)
通常被用来将对象的常量性转除(cast away the constness)
dynamic_cast(expression)
执行“安全向下转型”,也就是用来决定某对象是否归属继承体系中的某个类型。
reinterpret_cast(expression)
执行低级转型 //不太懂??
static_cast(expression)
强迫隐式转换
...
分类:
编程语言 时间:
2014-07-10 23:19:18
阅读次数:
250
当listview的某个item选中时,默认有个选中的高亮显示,如果你要自定义选中时的高亮显示效果,可以在listview中设置属性
1
android:listSelector="@drawable/item_selector"
其中item_selector是在drawable目录下定义的一个xml文件,这...
分类:
其他好文 时间:
2014-07-10 20:19:58
阅读次数:
292
经验:当std::swap对你的类型效率不高时,提供一个swap成员函数,并确定这个函数不抛出异常
示例:
stl里的swap算法
namespace std{
template
void swap(T &a, T &b){
T temp(a);
a = b;
b = temp;
}
}
//“pimpl手法”(pointer to implementation) --> 文件间的编译依存度
class WidgetImpl{
public:
//...
pr...
分类:
编程语言 时间:
2014-07-10 19:35:50
阅读次数:
240
经验:尽可能延后变量定义式的出现。这样做可增加程序的清晰度并改善程序效率。
示例:
//这个函数过早定义变量“encrypted”
std::string encryptPassword(const std::string &password){
using namespace std;
string encrypted;
if(password.length() < MinimumPasswordLength){
throw logic_error("Password is too short"...
分类:
编程语言 时间:
2014-07-10 19:27:30
阅读次数:
253