-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.html
299 lines (203 loc) · 11.1 KB
/
index2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<title>philokey的笔记</title>
<meta name="description" content="">
<meta name="author" content="philokey">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="./theme/html5.js"></script>
<![endif]-->
<!-- Le styles -->
<link href="./theme/bootstrap.min.css" rel="stylesheet">
<link href="./theme/bootstrap.min.responsive.css" rel="stylesheet">
<link href="./theme/local.css" rel="stylesheet">
<link href="./theme/pygments.css" rel="stylesheet">
<!-- So Firefox can bookmark->"abo this site" -->
<link href="http://www.philokey.com/feeds/all.atom.xml" rel="alternate" title="philokey的笔记" type="application/atom+xml">
<link href="http://www.philokey.com/feeds/all.rss.xml" rel="alternate" title="philokey的笔记" type="application/rss+xml">
</head>
<body>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href=".">philokey的笔记</a>
<div class="nav-collapse">
<ul class="nav">
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<div class="content">
<div class="row">
<div class="span9">
<div class='article'>
<a href="./pages/2014/08/13/python-ke-bian-dui-xiang-he-bu-ke-bian-dui-xiang.html"><h2>python 可变对象和不可变对象</h2></a>
<div class= "well small"> 2014-08-13
by <a class="url fn" href="./author/philokey.html">philokey</a>
</div>
<div class="summary"><p>Python中没有变量,只有对象和名字。万物皆对象。
每个对象都包含一一个标准头,通过头部信息就可以明确知道其具体类型。
头信息由 "引用用计数" 和 "类型指针"组成,前者在对象被引用用时增加,超出作用用域或手工释放后减小,等于 0 时会被虚拟机回收 (某些被缓存的对象计数器永远不会为 0)。用 </p>
<div class="highlight"><pre>sys.getrefcount(name)
</pre></div>
<p>可以对象查看被引用次数</p>
<p>Python在heap中分配的对象分成两类:可变对象和不可变对象。所谓可变对象是指,对象的内容是可变的,例如list。而不可变的对象则相反,表示其内容不可变。</p>
<ul>
<li>不可变对象:int,string,float,tuple</li>
<li>可变对象 :list,dictionary</li>
</ul>
<h2>不可变对象</h2>
<p>对于不可变对象,尽管对象本身不可变,但名字的对象引用是可变的。</p>
<div class="highlight"><pre>>>> a = 1005
>>> a = 1006 #1005的引用减1, 1006的引用加1,或者是创建的新的对象1006
#不可变对象字符串
>>> str ...</pre></div> <a class="btn btn-info xsmall" href="./pages/2014/08/13/python-ke-bian-dui-xiang-he-bu-ke-bian-dui-xiang.html">read more</a></div>
</div>
<div class='article'>
<a href="./pages/2014/08/10/stlbi-ji.html"><h2>STL笔记</h2></a>
<div class= "well small"> 2014-08-10
by <a class="url fn" href="./author/philokey.html">philokey</a>
</div>
<div class="summary"><h2>priority_queue自定义比较函数</h2>
<p>模板声明带有三个参数</p>
<div class="highlight"><pre>priority_queue<Type, Container, Functional>
</pre></div>
<p>Type 为数据类型, Container 为保存数据的容器,Functional 为元素比较方式。
Container 必须是用数组实现的容器,比如 vector, deque 但不能用 list.
STL里面默认用的是 vector. 比较方式默认用 operator< , 所以默认为小根堆。</p>
<div class="highlight"><pre><span class="cp">#include < iostream ></span>
<span class="cp">#include < queue ></span>
<span class="cp">#include < functional ></span>
<span class="k">using</span> <span class="k">namespace</span> <span class="n">std</span><span class="p">;</span>
<span class="k">class</span> <span class="nc">cmp</span> <span class="p">{</span>
<span class="k">public</span><span class="o">:</span>
<span class="kt">bool</span> <span class="k">operator</span><span class="p">()</span> <span class="p">(</span><span class="k">const</span> <span class="kt">int</span><span class="o">&</span> <span class="n">a</span><span class="p">,</span> <span class="k">const</span> <span class="kt">int</span><span class="o">&</span> <span class="n">b</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="n">a</span> <span class="o">></span> <span class="n">b</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">};</span>
<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span>
<span class="n">priority_queue ...</span></pre></div> <a class="btn btn-info xsmall" href="./pages/2014/08/10/stlbi-ji.html">read more</a></div>
</div>
<div class='article'>
<a href="./pages/2014/08/01/bo-ke-da-jian-ji-lu.html"><h2>博客搭建记录</h2></a>
<div class= "well small"> 2014-08-01
by <a class="url fn" href="./author/philokey.html">philokey</a>
</div>
<div class="summary"><p>厌倦了一次又一次去搜相同问题的答案,写个博客把一些东西记录下来吧。
出于黑客精神,决定自己搭建博客。</p>
<p>Wordpress过于庞大,而且我不会PHP,所以选择了基于python的pelican。
由于github有免费的300M空间,所以博客托管再github上。github还有一个好处就是对markdown的支持不错。</p>
<p>不用数据库,全部都以可见文本形式存储,携带迁移,好开心~</p>
<p>2015.11.29 update</p>
<p>谢天谢地有这篇搭建笔记,重新把博客搭起来并迁移到了Python3,真感人。</p>
<h2>本地配置Pelican</h2>
<h3>安装pelican和markdown</h3>
<div class="highlight"><pre>pip install pelican
pip install markdown
</pre></div>
<h3>启动工程</h3>
<div class="highlight"><pre>pelican-quickstart
</pre></div>
<p>目录树如下</p>
<div class="highlight"><pre>├── content #存放.mdn文件
├── develop_server.sh #方便开启测试服务器
├── fabfile.py #配置文件
├── Makefile #方便管理博客的Makefile
├── output #生成的输出文件
├── pelicanconf.py #主配置文件
└── publishconf.py ...</pre></div> <a class="btn btn-info xsmall" href="./pages/2014/08/01/bo-ke-da-jian-ji-lu.html">read more</a></div>
</div>
<div class='article'>
<a href="./pages/2014/08/01/hello-world.html"><h2>hello world</h2></a>
<div class= "well small"> 2014-08-01
by <a class="url fn" href="./author/philokey.html">philokey</a>
</div>
<div class="summary"><h3>Hello World</h3>
<div class="highlight"><pre><span class="cp">#include <cstdio></span>
<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span>
<span class="n">printf</span><span class="p">(</span><span class="s">"Hello World</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p><img alt="测试图片" src="https://lh4.googleusercontent.com/-mPNwHFX9qac/UQOGgQHjkcI/AAAAAAAAABA/YU7VaS0I2fs/s149/1131410.png" /></p> <a class="btn btn-info xsmall" href="./pages/2014/08/01/hello-world.html">read more</a></div>
</div>
<div class="pagination">
<ul>
<li class="prev"><a href="./index.html">← Previous</a></li>
<li class=""><a href="./index.html">1</a></li>
<li class="active"><a href="./index2.html">2</a></li>
<li class="next disabled"><a href="#">→ Next</a></li>
</ul>
</div>
</div>
<div class="span3">
<div class="well" style="padding: 8px 0; background-color: #FBFBFB;">
<ul class="nav nav-list">
<li class="nav-header">
Site
</li>
<li><a href="./archives.html">Archives</a>
<li><a href="./tags.html">Tags</a>
<li><a href="http://www.philokey.com/feeds/all.atom.xml" rel="alternate">Atom feed</a></li>
<li><a href="http://www.philokey.com/feeds/all.rss.xml" rel="alternate">RSS feed</a></li>
</ul>
</div>
<div class="well" style="padding: 8px 0; background-color: #FBFBFB;">
<ul class="nav nav-list">
<li class="nav-header">
Categories
</li>
<li><a href="./category/bi-ji.html">笔记</a></li>
<li><a href="./category/c.html">C++</a></li>
<li><a href="./category/leetcode.html">LeetCode</a></li>
<li><a href="./category/linux.html">Linux</a></li>
<li><a href="./category/lun-wen.html">论文</a></li>
<li><a href="./category/lun-wen-caffemxnet.html">论文,caffe,mxnet</a></li>
<li><a href="./category/python.html">python</a></li>
<li><a href="./category/scala.html">Scala</a></li>
<li><a href="./category/za.html">杂</a></li>
</ul>
</div>
<div class="well" style="padding: 8px 0; background-color: #FBFBFB;">
<ul class="nav nav-list">
<li class="nav-header">
Links
</li>
<li><a href="http://getpelican.com/">Pelican</a></li>
<li><a href="http://python.org/">Python.org</a></li>
<li><a href="https://www.google.com/ncr">Google</a></li>
</ul>
</div>
<div class="social">
<div class="well" style="padding: 8px 0; background-color: #FBFBFB;">
<ul class="nav nav-list">
<li class="nav-header">
Social
</li>
<li><a href="https://github.com/philokey">Github</a></li>
<li><a href="http://weibo.com/u/1690959514/">微博</a></li>
</ul>
</div>
</div>
</div>
</div> </div>
<footer>
<br />
<p><a href=".">philokey的笔记</a> © philokey 2015</p>
</footer>
</div> <!-- /container -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="./theme/bootstrap-collapse.js"></script>
<script>var _gaq=[['_setAccount','UA-53439918-1'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script'))</script>
</body>
</html>