﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-C/C++/Linux/Embedded</title><link>http://www.cppblog.com/fenixchen/</link><description>学习也是一种乐趣</description><language>zh-cn</language><lastBuildDate>Mon, 13 Apr 2026 06:56:04 GMT</lastBuildDate><pubDate>Mon, 13 Apr 2026 06:56:04 GMT</pubDate><ttl>60</ttl><item><title>遍历删除vector的中的元素</title><link>http://www.cppblog.com/fenixchen/archive/2007/05/08/23611.html</link><dc:creator>陈长虹</dc:creator><author>陈长虹</author><pubDate>Tue, 08 May 2007 02:43:00 GMT</pubDate><guid>http://www.cppblog.com/fenixchen/archive/2007/05/08/23611.html</guid><wfw:comment>http://www.cppblog.com/fenixchen/comments/23611.html</wfw:comment><comments>http://www.cppblog.com/fenixchen/archive/2007/05/08/23611.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/fenixchen/comments/commentRss/23611.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/fenixchen/services/trackbacks/23611.html</trackback:ping><description><![CDATA[<p><font style="BACKGROUND-COLOR: #d5e7fb">一般来说vector不适合做经常删除的容器,但是在某些情况下,我们确实需要删除vector的部分元素,一般的方式类为v.erase(remove_if(v.begin(), v.end(), func)).但是本人懒的把操做写到另一个函数中,下面是一个更好的办法<br></p>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">vector</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">::reverse_iterator&nbsp;rit&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;v.rbegin();<br></span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;(rit&nbsp;</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">&nbsp;v.rbegin())<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(func(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">rit))&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">检查是否需要删除</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v.erase((</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">rit).</span><span style="COLOR: #0000ff">base</span><span style="COLOR: #000000">());<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">rit;<br>}</span></div>
<p>其中reverse_iterator和iterator的关系与转换是关键,STL真是设计的强大.<br><br></font></p>
<img src ="http://www.cppblog.com/fenixchen/aggbug/23611.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/fenixchen/" target="_blank">陈长虹</a> 2007-05-08 10:43 <a href="http://www.cppblog.com/fenixchen/archive/2007/05/08/23611.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个VIM的脚本</title><link>http://www.cppblog.com/fenixchen/archive/2007/03/31/20988.html</link><dc:creator>陈长虹</dc:creator><author>陈长虹</author><pubDate>Sat, 31 Mar 2007 02:26:00 GMT</pubDate><guid>http://www.cppblog.com/fenixchen/archive/2007/03/31/20988.html</guid><wfw:comment>http://www.cppblog.com/fenixchen/comments/20988.html</wfw:comment><comments>http://www.cppblog.com/fenixchen/archive/2007/03/31/20988.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/fenixchen/comments/commentRss/20988.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/fenixchen/services/trackbacks/20988.html</trackback:ping><description><![CDATA[使用VIM编写程序,发现切换头文件和代码文件很麻烦,发现一个好东西A.vim,具体使用参数如下:<br />A switches to the header file corresponding to the current file being edited (or vise versa) <br />:AS splits and switches <br />:AV vertical splits and switches <br />:AT new tab and switches <br />:AN cycles through matches <br />:IH switches to file under cursor <br />:IHS splits and switches <br />:IHV vertical splits and switches <br />:IHT new tab and switches <br />:IHN cycles through matches <br />&lt;Leader&gt;ih switches to file under cursor <br />&lt;Leader&gt;is switches to the alternate file of file under cursor (e.g. on  &lt;foo.h&gt; switches to foo.cpp) <br />&lt;Leader&gt;ihn cycles through matches <br />下载地址如下:http://www.vim.org/scripts/script.php?script_id=31<br />下载后放到/usr/share/vim/vim61/plugin/就可以了,如果启动时候有错误,就下载一个老一点的版本.<img src ="http://www.cppblog.com/fenixchen/aggbug/20988.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/fenixchen/" target="_blank">陈长虹</a> 2007-03-31 10:26 <a href="http://www.cppblog.com/fenixchen/archive/2007/03/31/20988.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>indent工具参数</title><link>http://www.cppblog.com/fenixchen/archive/2007/03/31/20987.html</link><dc:creator>陈长虹</dc:creator><author>陈长虹</author><pubDate>Sat, 31 Mar 2007 02:12:00 GMT</pubDate><guid>http://www.cppblog.com/fenixchen/archive/2007/03/31/20987.html</guid><wfw:comment>http://www.cppblog.com/fenixchen/comments/20987.html</wfw:comment><comments>http://www.cppblog.com/fenixchen/archive/2007/03/31/20987.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/fenixchen/comments/commentRss/20987.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/fenixchen/services/trackbacks/20987.html</trackback:ping><description><![CDATA[indent是一个常用的Linux的C代码格式化工具,但是参数太多,很难记忆,目前发现一组参数,可以格式化为我常用的代码格式.<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">-</span><span style="COLOR: #000000">bad </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">bap </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">bbb </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">bbo </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">nbc </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">bl </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">bli0 </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">bls </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">c33 </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">cd33 </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">ncdb </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">ncdw </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">nce </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">cli0 </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">cp33 </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">cs </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">d0 </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">nbfda  </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">nfc1 </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">nfca </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">hnl </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">ip5 </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">l75 </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">l<br />p </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">pcs </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">nprs </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">saf </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">sai </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">saw </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">nsc </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">nsob </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">nss </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">i4 </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">ts4 </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">ut</span></div>保存在~/.indent.pro,就是默认的indent参数了.<br /><img src ="http://www.cppblog.com/fenixchen/aggbug/20987.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/fenixchen/" target="_blank">陈长虹</a> 2007-03-31 10:12 <a href="http://www.cppblog.com/fenixchen/archive/2007/03/31/20987.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>开张了</title><link>http://www.cppblog.com/fenixchen/archive/2007/03/12/19633.html</link><dc:creator>陈长虹</dc:creator><author>陈长虹</author><pubDate>Mon, 12 Mar 2007 07:20:00 GMT</pubDate><guid>http://www.cppblog.com/fenixchen/archive/2007/03/12/19633.html</guid><wfw:comment>http://www.cppblog.com/fenixchen/comments/19633.html</wfw:comment><comments>http://www.cppblog.com/fenixchen/archive/2007/03/12/19633.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/fenixchen/comments/commentRss/19633.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/fenixchen/services/trackbacks/19633.html</trackback:ping><description><![CDATA[
		<p>
				<font style="BACKGROUND-COLOR: #c8e3e3">从Google上发现了这个C++专门的Blog,发现很不错,有自己写的欲望了,申请了一下,今天开张,希望能记录一些经验,保存一些自己看到的比较好的文章.</font>
		</p>
<img src ="http://www.cppblog.com/fenixchen/aggbug/19633.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/fenixchen/" target="_blank">陈长虹</a> 2007-03-12 15:20 <a href="http://www.cppblog.com/fenixchen/archive/2007/03/12/19633.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>