<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="http://feeds.qzone.qq.com/rss.xsl" version="1.0"?>
<rss version="2.0" xmlns:qz="http://qzone.qq.com">
<channel>
<title><![CDATA[ifree       ]]></title>
<description><![CDATA[╱/●.``簡單空間╬▓]]></description>
<link>http://236540107.qzone.qq.com</link>
<lastBuildDate>Sun, 29 Nov 2009 03:06:38 GMT</lastBuildDate>
<generator>Qzone</generator>
<language>zh-cn</language>
<copyright>Copyright (C), 2005-2008, Tencent Tech. Co., Ltd.</copyright>
<pubDate>Tue, 10 Nov 2009 20:59:54 GMT</pubDate>

<item>
<title><![CDATA[蓝莲花，永不凋零]]></title>
<link>http://236540107.qzone.qq.com/blog/1257886794</link>
<description><![CDATA[我对未来的所有信心来源于：<br><br>没有人喜欢谎言，人们喜欢真实。没有人喜欢虚伪，人们喜欢真诚。没有人喜欢欺诈，人们喜欢诚信。没有人喜欢卑劣，人们喜欢高尚。没有人喜欢怯懦，人们喜欢勇敢。没有人喜欢逃避，人们喜欢担当。甚至当这一切美德都不复存在的时候，人们依然在内心深处小声表示自己的欣赏。<br><br>人们喜欢小婴儿清澈透明的眼睛，也希望自己能有这样的一双眼睛。人们喜欢握住情人的手沉沉入睡，没有人会愿意永远在枕头下面放一把匕首。人们喜欢干净的阳光、天空、饮水和空气，没有愿意带着防毒面具和检测试纸在这世界上生活。人们喜欢面露微笑表情轻松，没有人愿意生活在恐惧之中，没有人愿意每多过一天都像是一种恩赐。人们喜欢平等如同甘霖一样普降大地，润泽万物，没有人喜欢被歧视、被压榨、被排挤、被盘算、被牺牲。是的，我在所有的不快乐中清晰地看到了对它们的渴求。<br><br>在所有不得不说的话，不得不做的事，乃至不得不唱的歌之后，还有不情愿存在，还有反讽在耳语，还有别过头去根本不转过来的眼神。在父母的怀抱里，在情人的口唇处，在朋友的肩膀上，还有另外一种生活另外一种情感留存。还是有拥抱和吻顽固地在坚持，还是有花朵在春天里顽强地开放，还是有麦子肩并肩顽抗一样沉默地站立在土地里。<br><br>人们在最简陋的阳台上也要种上花，在最廉价的地板上也要铺上地胶，在最小最破败的房间里也要点上一盏灯，所以我对未来依然抱有希望，相信世间的确存在着蓝莲花。<br><br>那花一直在盛放，永不凋零。<br> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[236540107@qq.com(ifree       )]]></author>
<comments>http://236540107.qzone.qq.com/blog/1257886794#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Tue, 10 Nov 2009 20:59:54 GMT</pubDate>
<guid>http://236540107.qzone.qq.com/blog/1257886794</guid>
</item>

<item>
<title><![CDATA[Mouse Capturing]]></title>
<link>http://236540107.qzone.qq.com/blog/1256472768</link>
<description><![CDATA[<br>A basic building block for drag operations in qooxdoo is a conceptcalled mouse capturing. It was fist introduced by Microsoft withInternet Explorer 5 but unfortunately no other browser vendor hasimplemented it (<a href="http://msdn.microsoft.com/en-us/library/ms537630%28VS.85%29.aspx" target="_blank">MSDN</a><wbr />).Mouse capturing allows web developers to tell the browser that allmouse events should be dispatched on the same DOM element. This isespecially useful for drag operations or menus, when all mouse eventsshould go to the dragged element even if the mouse cursor is notdirectly above the element.<br>This can be easily demonstrated by looking at a simplistic drag and drop implementation:<br> <br><span style="color:#03366;line-height:1.8em;">function</span><wbr /> draggable<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />element<span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> <span style="color:#66cc66;line-height:1.8em;">{</span><wbr /><br>    <span style="color:#03366;line-height:1.8em;">var</span><wbr /> dragging = <span style="color:#03366;line-height:1.8em;">null</span><wbr />;<br> <br>    addListener<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />element, <span style="color:#3366cc;line-height:1.8em;">&quot;mousedown&quot;</span><wbr />, <span style="color:#03366;line-height:1.8em;">function</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> <span style="color:#66cc66;line-height:1.8em;">{</span><wbr /><br>        <span style="color:#03366;line-height:1.8em;">var</span><wbr /> e = window.<span style="color:#0660;line-height:1.8em;">event</span><wbr />;<br>        dragging = <span style="color:#66cc66;line-height:1.8em;">{</span><wbr /><br>            mouseX: e.<span style="color:#0660;line-height:1.8em;">clientX</span><wbr />,<br>            mouseY: e.<span style="color:#0660;line-height:1.8em;">clientY</span><wbr />,<br>            startX: parseInt<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />element.<span style="color:#0660;line-height:1.8em;">style</span><wbr />.<span style="color:#0660;line-height:1.8em;">left</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />,<br>            startY: parseInt<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />element.<span style="color:#0660;line-height:1.8em;">style</span><wbr />.<span style="color:#0660;line-height:1.8em;">top</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /><br>        <span style="color:#66cc66;line-height:1.8em;">}</span><wbr />;<br>        element.<span style="color:#0660;line-height:1.8em;">setCapture</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br>    <span style="color:#66cc66;line-height:1.8em;">}</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br> <br>    addListener<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />element, <span style="color:#3366cc;line-height:1.8em;">&quot;losecapture&quot;</span><wbr />, <span style="color:#03366;line-height:1.8em;">function</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> <span style="color:#66cc66;line-height:1.8em;">{</span><wbr /><br>        dragging = <span style="color:#03366;line-height:1.8em;">null</span><wbr />;<br>    <span style="color:#66cc66;line-height:1.8em;">}</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br> <br>    addListener<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />element, <span style="color:#3366cc;line-height:1.8em;">&quot;mousemove&quot;</span><wbr />, <span style="color:#03366;line-height:1.8em;">function</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> <span style="color:#66cc66;line-height:1.8em;">{</span><wbr /><br>        <span style="color:#0066;line-height:1.8em;">if</span><wbr /> <span style="color:#66cc66;line-height:1.8em;">(</span><wbr />!dragging<span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> <span style="color:#0066;line-height:1.8em;">return</span><wbr />;<br> <br>        <span style="color:#03366;line-height:1.8em;">var</span><wbr /> e = window.<span style="color:#0660;line-height:1.8em;">event</span><wbr />;<br>        <span style="color:#03366;line-height:1.8em;">var</span><wbr /> top = dragging.<span style="color:#0660;line-height:1.8em;">startY</span><wbr /> + <span style="color:#66cc66;line-height:1.8em;">(</span><wbr />e.<span style="color:#0660;line-height:1.8em;">clientY</span><wbr /> - dragging.<span style="color:#0660;line-height:1.8em;">mouseY</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br>        <span style="color:#03366;line-height:1.8em;">var</span><wbr /> left = dragging.<span style="color:#0660;line-height:1.8em;">startX</span><wbr /> + <span style="color:#66cc66;line-height:1.8em;">(</span><wbr />e.<span style="color:#0660;line-height:1.8em;">clientX</span><wbr /> - dragging.<span style="color:#0660;line-height:1.8em;">mouseX</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br> <br>        element.<span style="color:#0660;line-height:1.8em;">style</span><wbr />.<span style="color:#0660;line-height:1.8em;">top</span><wbr /> = <span style="color:#66cc66;line-height:1.8em;">(</span><wbr />Math.<span style="color:#0660;line-height:1.8em;">max</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr /><span style="color:#cc00;line-height:1.8em;">0</span><wbr />, top<span style="color:#66cc66;line-height:1.8em;">)</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> + <span style="color:#3366cc;line-height:1.8em;">&quot;px&quot;</span><wbr />;<br>        element.<span style="color:#0660;line-height:1.8em;">style</span><wbr />.<span style="color:#0660;line-height:1.8em;">left</span><wbr /> = <span style="color:#66cc66;line-height:1.8em;">(</span><wbr />Math.<span style="color:#0660;line-height:1.8em;">max</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr /><span style="color:#cc00;line-height:1.8em;">0</span><wbr />, left<span style="color:#66cc66;line-height:1.8em;">)</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> + <span style="color:#3366cc;line-height:1.8em;">&quot;px&quot;</span><wbr />;<br>    <span style="color:#66cc66;line-height:1.8em;">}</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br><span style="color:#66cc66;line-height:1.8em;">}</span><wbr />;<br>draggable<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />document.<span style="color:#0660;line-height:1.8em;">getElementById</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr /><span style="color:#3366cc;line-height:1.8em;">&quot;drag&quot;</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />; <br><br> (works only in IE). While dragging try moving the cursor out of the browser window.<br>In the <span style="font-style:italic"><wbr />mousedown</span><wbr /> handler the current mouse and elementposition is stored in a drag session and then mouse capturing isstarted. From this point on all mouse events will be dispatched on thedragged element even if the mouse cursor is not over the element. Themouse can even leave the viewport as long as the mouse button ispressed. Mouse capturing ends when the mouse button is released, analert box is opened or the browser loses focus. Note that all listenerscan be attached directly to the element.<br>To get the same behavior in non IE browsers is a little bit trickybecause none do support mouse capturing. For this reason we cannotattach the <span style="font-style:italic"><wbr />mousemove</span><wbr /> listener to the dragged element. Instead we need to attach it to the <span style="font-style:italic"><wbr />document</span><wbr />. Since mouse events bubble up the DOM tree the <span style="font-style:italic"><wbr />document</span><wbr />will receive all move events. One problem with this approach is thatwhile bubbling up an intermediate event listener might manually stopthe bubbling by calling <span style="font-style:italic"><wbr />stopPropagation</span><wbr />. In this case theevent would never reach the document and the drag would be broken. Tofix this we have to attach the listeners to the event capturing phase.This can be easily confused with mouse capturing but it has nothing todo with it. In the W3C <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html" target="_blank">DOM event model</a><wbr />bubbling events have two phases. First in the capturing phase the eventbubbles from the document down to the event target. Afterwards in thebubbling phase it bubbles back from the target to the document. Thebubbling phase is much better known because IE doesn't support thecapturing phase at all. If the <span style="font-style:italic"><wbr />mousemove</span><wbr /> listener is added to the capturing phase of the <span style="font-style:italic"><wbr />document</span><wbr /> no other listener will be able to block it.<br> <br><span style="color:#03366;line-height:1.8em;">function</span><wbr /> draggable<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />element<span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> <span style="color:#66cc66;line-height:1.8em;">{</span><wbr /><br>    <span style="color:#03366;line-height:1.8em;">var</span><wbr /> dragging = <span style="color:#03366;line-height:1.8em;">null</span><wbr />;<br> <br>    addListener<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />element, <span style="color:#3366cc;line-height:1.8em;">&quot;mousedown&quot;</span><wbr />, <span style="color:#03366;line-height:1.8em;">function</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr />e<span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> <span style="color:#66cc66;line-height:1.8em;">{</span><wbr /><br>        <span style="color:#03366;line-height:1.8em;">var</span><wbr /> e = window.<span style="color:#0660;line-height:1.8em;">event</span><wbr /> || e;<br>        dragging = <span style="color:#66cc66;line-height:1.8em;">{</span><wbr /><br>            mouseX: e.<span style="color:#0660;line-height:1.8em;">clientX</span><wbr />,<br>            mouseY: e.<span style="color:#0660;line-height:1.8em;">clientY</span><wbr />,<br>            startX: parseInt<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />element.<span style="color:#0660;line-height:1.8em;">style</span><wbr />.<span style="color:#0660;line-height:1.8em;">left</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />,<br>            startY: parseInt<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />element.<span style="color:#0660;line-height:1.8em;">style</span><wbr />.<span style="color:#0660;line-height:1.8em;">top</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /><br>        <span style="color:#66cc66;line-height:1.8em;">}</span><wbr />;<br>        <span style="color:#0066;line-height:1.8em;">if</span><wbr /> <span style="color:#66cc66;line-height:1.8em;">(</span><wbr />element.<span style="color:#0660;line-height:1.8em;">setCapture</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> element.<span style="color:#0660;line-height:1.8em;">setCapture</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br>    <span style="color:#66cc66;line-height:1.8em;">}</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br> <br>    addListener<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />element, <span style="color:#3366cc;line-height:1.8em;">&quot;losecapture&quot;</span><wbr />, <span style="color:#03366;line-height:1.8em;">function</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> <span style="color:#66cc66;line-height:1.8em;">{</span><wbr /><br>        dragging = <span style="color:#03366;line-height:1.8em;">null</span><wbr />;<br>    <span style="color:#66cc66;line-height:1.8em;">}</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br> <br>    addListener<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />document, <span style="color:#3366cc;line-height:1.8em;">&quot;mouseup&quot;</span><wbr />, <span style="color:#03366;line-height:1.8em;">function</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> <span style="color:#66cc66;line-height:1.8em;">{</span><wbr /><br>        dragging = <span style="color:#03366;line-height:1.8em;">null</span><wbr />;<br>    <span style="color:#66cc66;line-height:1.8em;">}</span><wbr />, <span style="color:#03366;line-height:1.8em;">true</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br> <br>    <span style="color:#03366;line-height:1.8em;">var</span><wbr /> dragTarget = element.<span style="color:#0660;line-height:1.8em;">setCapture</span><wbr /> ? element : document;<br> <br>    addListener<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />dragTarget, <span style="color:#3366cc;line-height:1.8em;">&quot;mousemove&quot;</span><wbr />, <span style="color:#03366;line-height:1.8em;">function</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr />e<span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> <span style="color:#66cc66;line-height:1.8em;">{</span><wbr /><br>        <span style="color:#0066;line-height:1.8em;">if</span><wbr /> <span style="color:#66cc66;line-height:1.8em;">(</span><wbr />!dragging<span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> <span style="color:#0066;line-height:1.8em;">return</span><wbr />;<br> <br>        <span style="color:#03366;line-height:1.8em;">var</span><wbr /> e = window.<span style="color:#0660;line-height:1.8em;">event</span><wbr /> || e;<br>        <span style="color:#03366;line-height:1.8em;">var</span><wbr /> top = dragging.<span style="color:#0660;line-height:1.8em;">startY</span><wbr /> + <span style="color:#66cc66;line-height:1.8em;">(</span><wbr />e.<span style="color:#0660;line-height:1.8em;">clientY</span><wbr /> - dragging.<span style="color:#0660;line-height:1.8em;">mouseY</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br>        <span style="color:#03366;line-height:1.8em;">var</span><wbr /> left = dragging.<span style="color:#0660;line-height:1.8em;">startX</span><wbr /> + <span style="color:#66cc66;line-height:1.8em;">(</span><wbr />e.<span style="color:#0660;line-height:1.8em;">clientX</span><wbr /> - dragging.<span style="color:#0660;line-height:1.8em;">mouseX</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br> <br>        element.<span style="color:#0660;line-height:1.8em;">style</span><wbr />.<span style="color:#0660;line-height:1.8em;">top</span><wbr /> = <span style="color:#66cc66;line-height:1.8em;">(</span><wbr />Math.<span style="color:#0660;line-height:1.8em;">max</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr /><span style="color:#cc00;line-height:1.8em;">0</span><wbr />, top<span style="color:#66cc66;line-height:1.8em;">)</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> + <span style="color:#3366cc;line-height:1.8em;">&quot;px&quot;</span><wbr />;<br>        element.<span style="color:#0660;line-height:1.8em;">style</span><wbr />.<span style="color:#0660;line-height:1.8em;">left</span><wbr /> = <span style="color:#66cc66;line-height:1.8em;">(</span><wbr />Math.<span style="color:#0660;line-height:1.8em;">max</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr /><span style="color:#cc00;line-height:1.8em;">0</span><wbr />, left<span style="color:#66cc66;line-height:1.8em;">)</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /> + <span style="color:#3366cc;line-height:1.8em;">&quot;px&quot;</span><wbr />;<br>    <span style="color:#66cc66;line-height:1.8em;">}</span><wbr />, <span style="color:#03366;line-height:1.8em;">true</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br><span style="color:#66cc66;line-height:1.8em;">}</span><wbr />;<br> <br>draggable<span style="color:#66cc66;line-height:1.8em;">(</span><wbr />document.<span style="color:#0660;line-height:1.8em;">getElementById</span><wbr /><span style="color:#66cc66;line-height:1.8em;">(</span><wbr /><span style="color:#3366cc;line-height:1.8em;">&quot;drag&quot;</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr /><span style="color:#66cc66;line-height:1.8em;">)</span><wbr />;<br> <br><br><br>If a mouse button is pressed and dragged out of the browser window, Firefox will continue to fire mouse events on the <span style="font-style:italic"><wbr />document</span><wbr />. Opera, Safari and Chrome are a little more tolerant and fire the events on the <span style="font-style:italic"><wbr />document.documentElement</span><wbr /> as well. For this reason we must attach the listener to the <span style="font-style:italic"><wbr />document</span><wbr /> and not the <span style="font-style:italic"><wbr />document.documentElement</span><wbr /> or <span style="font-style:italic"><wbr />document.body</span><wbr />.<br>Because if its usefulness we emulate the IE mouse capturing behaviorin our cross browser event handling layer. The fix for IE was to callthe native <span style="font-style:italic"><wbr />setCapture</span><wbr /> method. Since we used the emulatedmouse capturing support for IE as well we've lost the side effect ofreceiving mouse events when the mouse left the browser window. InFirefox we just had to switch the event target from <span style="font-style:italic"><wbr />document.documentElement</span><wbr /> to <span style="font-style:italic"><wbr />document</span><wbr />in our generic mouse event handler. With both fixes in place, mousecapturing and drag and drop operations now really work as expected onall supported browsers. <!--v:3.2--> ]]></description>
<category><![CDATA[电脑编程]]></category>
<author><![CDATA[236540107@qq.com(ifree       )]]></author>
<comments>http://236540107.qzone.qq.com/blog/1256472768#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Sun, 25 Oct 2009 12:12:48 GMT</pubDate>
<guid>http://236540107.qzone.qq.com/blog/1256472768</guid>
</item>

<item>
<title><![CDATA[And you think you're so clever and classless and free]]></title>
<link>http://236540107.qzone.qq.com/blog/1256464861</link>
<description><![CDATA[<div style="text-align:center;"><span style="font-style:italic"><wbr />And you think you're so clever and classless and free</span><wbr /></div><div style="text-align:center;">— John Lennon</div><br><a href="http://www.crockford.com/javascript" target="_blank">JavaScript</a><wbr /> is a <span style="font-style:italic"><wbr />class-free</span><wbr />, object-oriented language, and as such,it uses prototypal inheritance instead of classical inheritance. This can bepuzzling to programmers trained  in  conventional object-oriented languageslike C++ and Java. JavaScript's prototypal inheritance  has more expressivepower than classical inheritance, as we will see presently.      Java    JavaScript        Strongly-typed    Loosely-typed        Static    Dynamic        Classical    Prototypal        Classes    Functions        Constructors    Functions        Methods    Functions  <br>But first, why do we care about inheritance at all? There are primarily tworeasons. The first is type convenience. We want the language system toautomatically <span style="font-style:italic"><wbr />cast</span><wbr /> references of similar classes. Little type-safety isobtained from a type system which requires the routine explicit  casting ofobject references. This is of critical importance in strongly-typed languages,but it is irrelevant in loosely-typed languages like JavaScript, where objectreferences  never need casting.<br>The second reason is code reuse. It is very common to have a quantity of objects  all implementing exactly the same methods. Classes make it possible to create  them all from a single set of definitions. It is also common to have objects  that are similar to some other objects, but differing only in the addition or  modification of a small number of methods. Classical inheritance is useful for  this but prototypal inheritance is even more useful. <br>To demonstrate this, we will introduce a little <a href="http://javascript.crockford.com/inheritance.html#sugar" target="_blank">sugar</a><wbr />  which will let us write in a style that resembles a conventional classical language.  We will then show useful patterns which are not available in classical languages.  Then finally, we will explain the <a href="http://javascript.crockford.com/inheritance.html#sugar" target="_blank">sugar</a><wbr />. Classical Inheritance<br>First, we will make a Parenizor class that will have  set and getmethods for its value, and a toString method that will wrapthe value in parens. <br>function Parenizor(value) {<br>    this.setValue(value);<br>}<br><br>Parenizor.method('setValue', function (value) {<br>    this.value = value;<br>    return this;<br>});<br><br>Parenizor.method('getValue', function () {<br>    return this.value;<br>});<br><br>Parenizor.method('toString', function () {<br>    return '(' + this.getValue() + ')';<br>});<br><br>The syntax is a little unusual, but it is easy to recognize the classicalpattern in it. The method method takes a method name and a function,adding them to the class as a public method.<br>So now we can write<br>myParenizor = new Parenizor(0);<br>myString = myParenizor.toString();<br>As you would expect, myString is &quot;(0)&quot;.<br>Now we will make another class which will inherit from Parenizor,which is  the same except that its toString method willproduce &quot;-0-&quot; if the value is zero or empty.<br>function ZParenizor(value) {<br>    this.setValue(value);<br>}<br><br>ZParenizor.inherits(Parenizor);<br><br>ZParenizor.method('toString', function () {<br>    if (this.getValue()) {<br>        return this.uber('toString');<br>    }<br>    return &quot;-0-&quot;;<br>});<br><br>The inherits method is similar to Java's extends.The uber method is similar to Java's super. It lets a methodcall a method of  the parent class. (The names have been changed to avoidreserved word restrictions.)<br>So now we can write<br>myZParenizor = new ZParenizor(0);<br>myString = myZParenizor.toString();<br>This time, myString is &quot;-0-&quot;.<br>JavaScript does not have classes, but we can program as though it does.Multiple Inheritance<br>By manipulating a function's prototype object, we can implementmultiple inheritance, allowing us to make a class built from the methods ofmultiple classes.  Promiscuous multiple inheritance can be difficult toimplement and can potentially suffer from method name collisions. We couldimplement promiscuous multiple inheritance in JavaScript, but for this examplewe will use a more disciplined formcalled <span style="font-style:italic"><wbr /><a href="http://www.cosmik.com/aa-october99/stan_freberg.html" target="_blank">SwissInheritance</a><wbr /></span><wbr />.<br>Suppose there is a NumberValue class that has a setValuemethod that checks that the value is a number in a certain range,throwing an exception if necessary. We only wantits setValue and setRange methods for our ZParenizor.We certainly don't want its toString method. So, we write<br>ZParenizor.swiss(NumberValue, 'setValue', 'setRange');<br>This adds only the requested methods to our class.Parasitic Inheritance<br>There is another way to write ZParenizor. Instead of inheritingfrom Parenizor, we write a constructor that callsthe Parenizor constructor, passing off the result as its own.And instead of adding public methods,  the constructor adds  <a href="http://www.crockford.com/javascript/private.html" target="_blank">privileged methods</a><wbr />.<br>function ZParenizor2(value) {<br>    var that = new Parenizor(value);<br>    that.toString = function () {<br>        if (this.getValue()) {<br>            return this.uber('toString');<br>        }<br>        return &quot;-0-&quot;<br>    };<br>    return that;<br>}<br><br>Classical inheritance is about the <span style="font-style:italic"><wbr />is-a</span><wbr /> relationship, and parasitic  inheritance is about the <span style="font-style:italic"><wbr />was-a-but-now's-a</span><wbr /> relationship. The constructor  has a larger role in the construction of the object. Notice that the uber  née super method is still available to the privileged methods. Class Augmentation<br>JavaScript's dynamism allows us to add or replace methods of an existing class.  We can call the method method at any time, and all present and future  instances of the class will have that method. We can literally extend a class  at any time. Inheritance works retroactively. We call this <span style="font-style:italic"><wbr />Class Augmentation</span><wbr />  to avoid confusion with Java's extends, which means something else.Object Augmentation<br>In the static object-oriented languages, if you want an object which is slightly  different than another object, you need to define a new class. In JavaScript,  you can add methods to individual objects without the need for additional classes.  This has enormous power because you can write far fewer classes and the classes  you do write can be much simpler. Recall that JavaScript objects are like hashtables.  You can add new values at any time. If the value is a function, then it becomes  a method. <br>So in the example above, I didn't need a ZParenizor class at all.I could have simply modified my instance.<br>myParenizor = new Parenizor(0);<br>myParenizor.toString = function () {<br>    if (this.getValue()) {<br>        return this.uber('toString');<br>    }<br>    return &quot;-0-&quot;;<br>};<br>myString = myParenizor.toString();<br>We added a toString method to our myParenizor instance without  using any form of inheritance. We can evolve individual instances because the  language is class-free. Sugar<br>To make the examples above work, I wrote four <a href="http://en.wikipedia.org/wiki/Syntactic_sugar" target="_blank">sugar</a><wbr />  methods. First, the method method, which adds an instance method to  a class. <br>Function.prototype.method = function (name, func) {<br>    this.prototype[name] = func;<br>    return this;<br>};<br>This adds a public method to the Function.prototype, so allfunctions get it by Class Augmentation. It takes a name and a function, andadds them to a function's prototype object. <br>It returns this. When I write a method that doesn't need to return  a value, I usually have it return this. It allows for a cascade-style  of programming. <br>Next comes the inherits method, which indicates that one class inherits  from another. It should be called after both classes are defined, but before  the inheriting class's methods are added. <br>Function.method('inherits', function (parent) {<br>    var d = {}, p = (this.prototype = new parent());<br>    this.method('uber', function uber(name) {<br>        if (!(name in d)) {<br>            d[name] = 0;<br>        }        <br>        var f, r, t = d[name], v = parent.prototype;<br>        if (t) {<br>            while (t) {<br>                v = v.constructor.prototype;<br>                t -= 1;<br>            }<br>            f = v[name];<br>        } else {<br>            f = p[name];<br>            if (f == this[name]) {<br>                f = v[name];<br>            }<br>        }<br>        d[name] += 1;<br>        r = f.apply(this, Array.prototype.slice.apply(arguments, [1]));<br>        d[name] -= 1;<br>        return r;<br>    });<br>    return this;<br>});<br>Again, we augment Function. We make an instance of theparent class and use it as the new prototype. We alsocorrect the constructor field, and we add the uber method tothe prototype as well.<br>The uber method looks for the named method in its own prototype.  This is the function to invoke in the case of Parasitic Inheritance or Object  Augmentation. If we are doing Classical Inheritance, then we need to find the  function in the parent's prototype. The return statement  uses the function's apply method to invoke the function, explicitly  setting this and passing an array of parameters. The parameters (if  any) are obtained from the arguments array. Unfortunately, the  arguments  array is not a true array, so we have to use apply again to invoke  the array slice method. <br>Finally, the swiss method.<br>Function.method('swiss', function (parent) {<br>    for (var i = 1; i &lt; arguments.length; i += 1) {<br>        var name = arguments<span style="font-style:italic"><wbr />;<br>        this.prototype[name] = parent.prototype[name];<br>    }<br>    return this;<br>});<br>The swiss method loops through the arguments.For each name, it copies a member from the parent'sprototype to the new class's prototype.Conclusion<br>JavaScript can be used like a classical language, but it also has a level of  expressiveness which is quite unique. We have looked at Classical Inheritance,  Swiss Inheritance, Parasitic Inheritance, Class Augmentation, and Object Augmentation.  This large set of code reuse patterns comes from a language which is considered  smaller and simpler than Java. <br>Classical objects are hard. The only way to add a new member to ahard object is to create a new class. In JavaScript, objects are soft.A new member can be added to a soft object by simple assignment.<br>Because objects in JavaScript are so flexible, you will want to think   differently about class hierarchies. Deep hierarchies are inappropriate.   Shallow hierarchies are efficient and expressive.<br> I have been writing JavaScript   for 8 years now, and I have never once found need to use an uber   function. The super idea is fairly important in the classical   pattern, but it appears to be unnecessary in the prototypal and functional   patterns. I now see my early attempts to support the classical model in   JavaScript as a mistake. <!--v:3.2--> ]]></description>
<category><![CDATA[电脑编程]]></category>
<author><![CDATA[236540107@qq.com(ifree       )]]></author>
<comments>http://236540107.qzone.qq.com/blog/1256464861#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Sun, 25 Oct 2009 10:01:01 GMT</pubDate>
<guid>http://236540107.qzone.qq.com/blog/1256464861</guid>
</item>

<item>
<title><![CDATA[植物vs僵尸通关了!!!附作弊心得]]></title>
<link>http://236540107.qzone.qq.com/blog/1252835055</link>
<description><![CDATA[<embed invokeURLs="false" allowNetworking="internal" allowscriptaccess="never" menu="false" id="flash0" width="393" height="239" src="http://vhead.blog.sina.com.cn/player/outer_player.swf?auto=0&amp;vid=22752505&amp;uid=1136960113" /><br>这几天同学介绍了款游戏给我,植物大战僵尸,好一段时间没耍这种休闲游戏了,轻松下嘛（通关动画爽！）<br>周末回到家,打开游戏目录,习惯性的尽到了properties目录,打开LawnStrings文件,呵呵,汉化人员翻译的不错嘛,符合风格,呵呵,现在发几个在游戏里可以输入的东东,<br>------------------------------------------------------------------------------<br>试试在游戏时输入“futur<br>e”……以期会晤来自“未来”<br>的僵尸！如果你输入“trickedout”，不<br>要惊讶，如果你割草机上发生了<br>怪事。我听说输入“mustache”，会给<br>僵尸们带来惊人的改变！输入“daisies”，让僵尸 (智慧树100英尺)<br>们死的时候留下一朵小菊花。输入“dance”，让僵尸<br>们都摇摆起来吧！ (智慧树500英尺)<br>输入“pinata”，让僵尸们<br>死的时候吐出糖果，来庆祝吧！(智慧树1000英尺)<br>-----------------------------------------------------------------------------------------PopCap 真够黑的，智慧树要到1000 = =！~<br>不过不怕，我有的是钱，呵呵，现在说下刷钱，跳关<br>当然，这是通过修改存档来实现的，首先，打开c盘下的C:\ProgramData\PopCap Games\PlantsVsZombies\userdata\userx.dat文件（但是找了半天），用十六进制编辑软件打开，看第一排00000000h的6，7，8，9位，这就是存储钱和关数的，自己看着改吧，记到备份就是了，祝大家耍的愉快。<br>另推荐单机游戏快速过关工具（本人比较没耐心= =！~）变速齿轮，呵呵，游戏的时候就开2-4倍速，养花的时候就开32倍，呵呵，Enjoy Yourself!<br> <br> <!--v:3.2--> ]]></description>
<category><![CDATA[个人日记]]></category>
<author><![CDATA[236540107@qq.com(ifree       )]]></author>
<comments>http://236540107.qzone.qq.com/blog/1252835055#comment</comments>
<qz:effect>134222336</qz:effect>
<pubDate>Sun, 13 Sep 2009 09:44:15 GMT</pubDate>
<guid>http://236540107.qzone.qq.com/blog/1252835055</guid>
</item>

<item>
<title><![CDATA[MyEclipse注册码算法]]></title>
<link>http://236540107.qzone.qq.com/blog/1252426048</link>
<description><![CDATA[MyEclipse7.5也出来了，强大啊，还在为没有激活码而发愁吗，给大家个算法，呵呵，就是一个算法，看吧<br>先说这不是我写的哈，我也难得研究别人算法，只是翻译下老外的文章<br>import java.io.BufferedReader;<br>import java.io.IOException;<br>import java.io.InputStreamReader;<br>public class MyEclipseGen {<br>private static final String LL = &quot;反编译此注册码违反了别个的版权，有可能罚款，还可能遭关几年，自己在想想，不要触犯法律，让自己心里好过点&quot;;<br><br>public String getSerial(String userId, String licenseNum) {<br>   java.util.Calendar cal = java.util.Calendar.getInstance();<br>   cal.add(1, 3);<br>   cal.add(6, -1);<br>   java.text.NumberFormat nf = new java.text.DecimalFormat(&quot;000&quot;);<br>   licenseNum = nf.format(Integer.valueOf(licenseNum));<br>   String verTime = new StringBuilder(&quot;-&quot;).append(<br>     new java.text.SimpleDateFormat(&quot;yyMMdd&quot;).format(cal.getTime()))<br>     .append(&quot;0&quot;).toString();<br>   String type = &quot;YE3MP-&quot;;<br>   String need = new StringBuilder(userId.substring(0, 1)).append(type)<br>     .append(&quot;300&quot;).append(licenseNum).append(verTime).toString();<br>   String dx = new StringBuilder(need).append(LL).append(userId)<br>     .toString();<br>   int suf = this.decode(dx);<br>   String code = new StringBuilder(need).append(String.valueOf(suf))<br>     .toString();<br>   return this.change(code);<br>}<br><br>private int decode(String s) {<br>   int i;<br>   char[] ac;<br>   int j;<br>   int k;<br>   i = 0;<br>   ac = s.toCharArray();<br>   j = 0;<br>   k = ac.length;<br>   while (j &lt; k) {<br>    i = (31 * i) + ac[j];<br>    j++;<br>   }<br>   return Math.abs(i);<br>}<br><br>private String change(String s) {<br>   byte[] abyte0;<br>   char[] ac;<br>   int i;<br>   int k;<br>   int j;<br>   abyte0 = s.getBytes();<br>   ac = new char[s.length()];<br>   i = 0;<br>   k = abyte0.length;<br>   while (i &lt; k) {<br>    j = abyte0<span style="font-style:italic"><wbr />;<br>    if ((j &gt;= 48) &amp;&amp; (j &lt;= 57)) {<br>     j = (((j - 48) + 5) % 10) + 48;<br>    } else if ((j &gt;= 65) &amp;&amp; (j &lt;= 90)) {<br>     j = (((j - 65) + 13) % 26) + 65;<br>    } else if ((j &gt;= 97) &amp;&amp; (j &lt;= 122)) {<br>     j = (((j - 97) + 13) % 26) + 97;<br>    }<br>    ac<span style="font-style:italic"><wbr /> = (char) j;<br>    i++;<br>   }<br>   return String.valueOf(ac);<br>}<br><br>public MyEclipseGen() {<br>   super();<br>}<br><br>public static void main(String[] args) {<br>   try {<br>    System.out.println(&quot;please input register name:&quot;);<br>    BufferedReader reader = new BufferedReader(new InputStreamReader(<br>      System.in));<br>    String userId = null;<br>    userId = reader.readLine();<br>    MyEclipseGen myeclipsegen = new MyEclipseGen();<br>    String res = myeclipsegen.getSerial(userId, &quot;5&quot;);<br>    System.out.println(&quot;Serial:&quot; + res);<br>    reader.readLine();<br>   } catch (IOException ex) {<br>   }<br>}<br>} <!--v:3.2--> ]]></description>
<category><![CDATA[电脑编程]]></category>
<author><![CDATA[236540107@qq.com(ifree       )]]></author>
<comments>http://236540107.qzone.qq.com/blog/1252426048#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Tue, 08 Sep 2009 16:07:28 GMT</pubDate>
<guid>http://236540107.qzone.qq.com/blog/1252426048</guid>
</item>

<item>
<title><![CDATA[浅析.net 事件队列（欢迎拍砖）]]></title>
<link>http://236540107.qzone.qq.com/blog/1252260622</link>
<description><![CDATA[一直觉得微软的设计比较好，今天分析下事件队列嘛，呵呵<br>在winForm编程中我们经常会使用一些事件，比如说MouseClick,KeyPress等等，比如说一个按钮点击事件<br>btn_test.DoubleClick+=new EventHandler(void target); 这里的EventHandler是一个委托，定义如下:<br>public delegate void EventHandler(object sender,EventArgs e); DoubleClick的事件定义如下<br>public event EventHandler DoubleClick{<br>　　　　　　　　　　　　　　　　　add{base.DoubleClick+=value;}<br>　　　　　　　　　　　　　　　　　remove{base.DoubleClick-=value;}　<br>　　　　　　　　　　　　　　　　　}<br>我们看到base(当然是ButtonBase了才怪，是Control)里还有个DoubleClick事件，进去看看再说，呵呵，接近今天主题了，定义如下<br>public event EventHandler DoubleClick{<br>　　　　　　　　　　　　　　　　　add{base.Events.AddHandler(EventDoubleClick,value)}　　<br>　　　　　　　　　　　　　　　　　remove{base.Events.RemoveHandler(EventDoubleClick,Value)}　<br>　　　　　　　　　　　　　　　　 }<br>这里还有个base = =~! Component组件，这个就不说了，免得偏题了，后头再说。这里有个Events，不用说，肯定猜得到，事件的集合嘛，我们继续往里看，呵呵。Events的定义如下(这里的Events是Component的成员呵呵):<br>protected EventHandlerList events；//Events是一个只读属性，这里写出了字段<br>现在我们把重心转移到EventHandlerList里面来，我把代码贴出来大家方便研究，<br>[<span style="text-decoration:underline;"><wbr />HostProtection</span><wbr />(<span style="text-decoration:underline;"><wbr />SecurityAction</span><wbr />.<span style="text-decoration:underline;"><wbr />LinkDemand</span><wbr />, <span style="text-decoration:underline;"><wbr />SharedState</span><wbr />=true)]<br>public sealed class <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />EventHandlerList</span><wbr /></span><wbr /> : <span style="text-decoration:underline;"><wbr />IDisposable</span><wbr /><br>{<br>    // Fields<br>    private <span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /> <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />head</span><wbr /></span><wbr />;<br>    private <span style="text-decoration:underline;"><wbr />Component</span><wbr /> <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />parent</span><wbr /></span><wbr />;<br> <br>    // Methods<br>    public <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />EventHandlerList</span><wbr /></span><wbr />()<br>    {<br>    }<br> <br>    internal <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />EventHandlerList</span><wbr /></span><wbr />(<span style="text-decoration:underline;"><wbr />Component</span><wbr /> parent)<br>    {<br>        this.<span style="text-decoration:underline;"><wbr />parent</span><wbr /> = parent;<br>    }<br> <br>    public <span style="text-decoration:underline;"><wbr />void</span><wbr /> <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />AddHandler</span><wbr /></span><wbr />(<span style="text-decoration:underline;"><wbr />object</span><wbr /> key, <span style="text-decoration:underline;"><wbr />Delegate</span><wbr /> value)<br>    {<br>        <span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /> <span style="font-weight:bold"><wbr />entry</span><wbr /> = this.<span style="text-decoration:underline;"><wbr />Find</span><wbr />(key);<br>        if (entry != null)<br>        {<br>            entry.<span style="text-decoration:underline;"><wbr />handler</span><wbr /> = <span style="text-decoration:underline;"><wbr />Delegate</span><wbr />.<span style="text-decoration:underline;"><wbr />Combine</span><wbr />(entry.<span style="text-decoration:underline;"><wbr />handler</span><wbr />, value);<br>        }<br>        else<br>        {<br>            this.<span style="text-decoration:underline;"><wbr />head</span><wbr /> = new <span style="text-decoration:underline;"><wbr />ListEntry</span><wbr />(key, value, this.<span style="text-decoration:underline;"><wbr />head</span><wbr />);<br>        }<br>    }<br> <br>    public <span style="text-decoration:underline;"><wbr />void</span><wbr /> <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />AddHandlers</span><wbr /></span><wbr />(<span style="text-decoration:underline;"><wbr />EventHandlerList</span><wbr /> listToAddFrom)<br>    {<br>        for (<span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /> <span style="font-weight:bold"><wbr />entry</span><wbr /> = listToAddFrom.<span style="text-decoration:underline;"><wbr />head</span><wbr />; entry != null; entry = entry.<span style="text-decoration:underline;"><wbr />next</span><wbr />)<br>        {<br>            this.<span style="text-decoration:underline;"><wbr />AddHandler</span><wbr />(entry.<span style="text-decoration:underline;"><wbr />key</span><wbr />, entry.<span style="text-decoration:underline;"><wbr />handler</span><wbr />);<br>        }<br>    }<br> <br>    public <span style="text-decoration:underline;"><wbr />void</span><wbr /> <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />Dispose</span><wbr /></span><wbr />()<br>    {<br>        this.<span style="text-decoration:underline;"><wbr />head</span><wbr /> = null;<br>    }<br> <br>    private <span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /> <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />Find</span><wbr /></span><wbr />(<span style="text-decoration:underline;"><wbr />object</span><wbr /> key)<br>    {<br>        <span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /> <span style="font-weight:bold"><wbr />head</span><wbr /> = this.<span style="text-decoration:underline;"><wbr />head</span><wbr />;<br>        while (head != null)<br>        {<br>            if (head.<span style="text-decoration:underline;"><wbr />key</span><wbr /> == key)<br>            {<br>                return head;<br>            }<br>            head = head.<span style="text-decoration:underline;"><wbr />next</span><wbr />;<br>        }<br>        return head;<br>    }<br> <br>    public <span style="text-decoration:underline;"><wbr />void</span><wbr /> <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />RemoveHandler</span><wbr /></span><wbr />(<span style="text-decoration:underline;"><wbr />object</span><wbr /> key, <span style="text-decoration:underline;"><wbr />Delegate</span><wbr /> value)<br>    {<br>        <span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /> <span style="font-weight:bold"><wbr />entry</span><wbr /> = this.<span style="text-decoration:underline;"><wbr />Find</span><wbr />(key);<br>        if (entry != null)<br>        {<br>            entry.<span style="text-decoration:underline;"><wbr />handler</span><wbr /> = <span style="text-decoration:underline;"><wbr />Delegate</span><wbr />.<span style="text-decoration:underline;"><wbr />Remove</span><wbr />(entry.<span style="text-decoration:underline;"><wbr />handler</span><wbr />, value);<br>        }<br>    }<br> <br>    // Properties<br>    public <span style="text-decoration:underline;"><wbr />Delegate</span><wbr /> <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />this</span><wbr /></span><wbr />[<span style="text-decoration:underline;"><wbr />object</span><wbr /> key]<br>    {<br>        get<br>        {<br>            <span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /> <span style="font-weight:bold"><wbr />entry</span><wbr /> = null;<br>            if ((this.<span style="text-decoration:underline;"><wbr />parent</span><wbr /> == null) || this.<span style="text-decoration:underline;"><wbr />parent</span><wbr />.<span style="text-decoration:underline;"><wbr />CanRaiseEventsInternal</span><wbr />)<br>            {<br>                entry = this.<span style="text-decoration:underline;"><wbr />Find</span><wbr />(key);<br>            }<br>            if (entry != null)<br>            {<br>                return entry.<span style="text-decoration:underline;"><wbr />handler</span><wbr />;<br>            }<br>            return null;<br>        }<br>        set<br>        {<br>            <span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /> <span style="font-weight:bold"><wbr />entry</span><wbr /> = this.<span style="text-decoration:underline;"><wbr />Find</span><wbr />(key);<br>            if (entry != null)<br>            {<br>                entry.<span style="text-decoration:underline;"><wbr />handler</span><wbr /> = value;<br>            }<br>            else<br>            {<br>                this.<span style="text-decoration:underline;"><wbr />head</span><wbr /> = new <span style="text-decoration:underline;"><wbr />ListEntry</span><wbr />(key, value, this.<span style="text-decoration:underline;"><wbr />head</span><wbr />);<br>            }<br>        }<br>    }<br> <br>    // Nested Types<br>    private sealed class <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /></span><wbr /><br>    {<br>        // Fields<br>        internal <span style="text-decoration:underline;"><wbr />Delegate</span><wbr /> <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />handler</span><wbr /></span><wbr />;<br>        internal <span style="text-decoration:underline;"><wbr />object</span><wbr /> <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />key</span><wbr /></span><wbr />;<br>        internal <span style="text-decoration:underline;"><wbr />EventHandlerList</span><wbr />.<span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /> <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />next</span><wbr /></span><wbr />;<br> <br>        // Methods<br>        public <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /></span><wbr />(<span style="text-decoration:underline;"><wbr />object</span><wbr /> key, <span style="text-decoration:underline;"><wbr />Delegate</span><wbr /> handler, <span style="text-decoration:underline;"><wbr />EventHandlerList</span><wbr />.<span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /> next)<br>        {<br>            this.<span style="text-decoration:underline;"><wbr />next</span><wbr /> = next;<br>            this.<span style="text-decoration:underline;"><wbr />key</span><wbr /> = key;<br>            this.<span style="text-decoration:underline;"><wbr />handler</span><wbr /> = handler;<br>        }<br>    }<br>}<br> <br><span style="font-family:'Calibri';line-height:1.8em;">哈哈，明白了吧，微软写了个链表来实现队列，用ADT（抽象数据类型）来实现OOD（面向对象的设计），现在来分析下代码吧</span><wbr /><br><span style="font-family:'Calibri';line-height:1.8em;">刚刚说到AddHanders,把事件添加到委托链当中，因为链表的结构，所以每次执行多播委托的时候总是从链表头部开始执行，现在看看这个方法:</span><wbr /><br><span style="font-family:'Calibri';line-height:1.8em;"><span style="font-family:'宋体';line-height:1.8em;">  public <span style="text-decoration:underline;"><wbr />void</span><wbr /> <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />AddHandler</span><wbr /></span><wbr />(<span style="text-decoration:underline;"><wbr />object</span><wbr /> key, <span style="text-decoration:underline;"><wbr />Delegate</span><wbr /> value)</span><wbr /><br>    {<br>        <span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /> <span style="font-weight:bold"><wbr />entry</span><wbr /> = this.<span style="text-decoration:underline;"><wbr />Find</span><wbr />(key);<br>        if (entry != null)<br>        {<br>            entry.<span style="text-decoration:underline;"><wbr />handler</span><wbr /> = <span style="text-decoration:underline;"><wbr />Delegate</span><wbr />.<span style="text-decoration:underline;"><wbr />Combine</span><wbr />(entry.<span style="text-decoration:underline;"><wbr />handler</span><wbr />, value);<br>        }<br>        else<br>        {<br>            this.<span style="text-decoration:underline;"><wbr />head</span><wbr /> = new <span style="text-decoration:underline;"><wbr />ListEntry</span><wbr />(key, value, this.<span style="text-decoration:underline;"><wbr />head</span><wbr />);<br>        }<br>    }<br> <br>这里有个Delegate.Combine(Delegate d1,Delegate d2)表示绑定两个委托，而Find方法则体现了链表结构精髓<br> private <span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /> <span style="font-weight:bold"><wbr /><span style="text-decoration:underline;"><wbr />Find</span><wbr /></span><wbr />(<span style="text-decoration:underline;"><wbr />object</span><wbr /> key)<br>    {<br>        <span style="text-decoration:underline;"><wbr />ListEntry</span><wbr /> <span style="font-weight:bold"><wbr />head</span><wbr /> = this.<span style="text-decoration:underline;"><wbr />head</span><wbr />;<br>        while (head != null)<br>        {<br>            if (head.<span style="text-decoration:underline;"><wbr />key</span><wbr /> == key)<br>            {<br>                return head;<br>            }<br>            head = head.<span style="text-decoration:underline;"><wbr />next</span><wbr />;<br>        }<br>        return head;<br>    }<br></span><wbr />head = head.<span style="text-decoration:underline;"><wbr />next</span><wbr />;  呵呵典型的单链表，<br> 好了，就说到这里吧，大家研究下哈，我也该洗洗睡了，<img src="http://imgcache.qq.com/qzone/em/e120.gif"><wbr />。 <!--v:3.2--> ]]></description>
<category><![CDATA[电脑编程]]></category>
<author><![CDATA[236540107@qq.com(ifree       )]]></author>
<comments>http://236540107.qzone.qq.com/blog/1252260622#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Sun, 06 Sep 2009 18:10:22 GMT</pubDate>
<guid>http://236540107.qzone.qq.com/blog/1252260622</guid>
</item>

<item>
<title><![CDATA[qq空间游戏基地破解心得+教程[ifree原创]]]></title>
<link>http://236540107.qzone.qq.com/blog/1252057173</link>
<description><![CDATA[被一个朋友引诱到qq空间游戏基地，耍了几盘挖金子，每次都进步到排行，= =~！   一气之下就萌生了这个念头，破了这个垃圾游戏！<br>于是，黑暗开始降临大地，魔王复苏了！<img src="http://imgcache.qq.com/qzone/em/e120.gif"><wbr />  还是进入正题了<br>开始，游戏结束的时候我就抓他包，收获不咋大，结合反编译游戏源文件，发现TX游戏提交页面在这里<br><a href="http://isdimg0.qq.com/qzone/flashgames/com/comm.swf" target="_blank">http://isdimg0.qq.com/qzone/flashgames/com/comm.swf</a><wbr /><br>进而反编译之，TX线路信息如下（我这是网通，就是cnc）<br><a href="http://imgcache.qq.com/" target="_blank">http://imgcache.qq.com/</a><wbr />&quot;, &quot;<a href="http://cnc.imgcache.qq.com/" target="_blank">http://cnc.imgcache.qq.com/</a><wbr />&quot;, &quot;<a href="http://edu.imgcache.qq.com/" target="_blank">http://edu.imgcache.qq.com/</a><wbr />&quot;, &quot;<a href="http://isdimg0.qq.com/" target="_blank">http://isdimg0.qq.com/</a><wbr /><br>然后就是<br>var SUBMIT_URL = [&quot;<a href="http://hobby.qzone.qq.com/cgi-bin/game/play" target="_blank">http://hobby.qzone.qq.com/cgi-bin/game/play</a><wbr />&quot;, &quot;<a href="http://hobby.qzone.qq.com/cgi-bin/game/xyplay" target="_blank">http://hobby.qzone.qq.com/cgi-bin/game/xyplay</a><wbr />&quot;, &quot;<a href="http://hobby.qzone.qq.com/cgi-bin/game/cgi_bookpk_post_myscore" target="_blank">http://hobby.qzone.qq.com/cgi-bin/game/cgi_bookpk_post_myscore</a><wbr />&quot;, &quot;<a href="http://hobby.qzone.qq.com/cgi-bin/game/cgi_directpk_post_myscore" target="_blank">http://hobby.qzone.qq.com/cgi-bin/game/cgi_directpk_post_myscore</a><wbr />&quot;];这就是提交地址了，本来考虑用c#写webRequest的，发现密码验证要用三层md5，解析数据也比较麻烦，还有就是最近太忙了，那就写脚本操作嘛，于是，结合qq农场外挂经验，解析下面几组脚本，本人经验尚浅，前期遇到比较多困难<br> <br>到现在得到了TX游戏结果提交地址(SUBMIT_URL) 呵呵，<br>然后，main.js 这和happyFarm的一样嘛，可以进行下一步了，根据gameinfo.js游戏列表就出来了同时还发现了几个隐藏游戏，近期可能TX就会发布了整理如下'100'name : '采摘人参果','101' name : '俄罗斯方块','102'name : '大战潜艇','103' name : '是英雄就下100层','104'name : '最浪漫的舞蹈游戏','105'name : '挖金矿','110' name : '安全任务','111' name : '冒险岛', '112' name : '神秘宝藏','113'name : '史努比射箭','114'name : '泰迪学游泳','115'name : '中国龙之遗失的宝藏','116'name : '喜羊羊连连看','117'name : '旋转水果','118'name : '天使任务','119'name : '怪物对对碰','120'name : '兔子吃萝卜',/*'121'name : '钓鱼',。。。。。。。。。。还有几个，不发了，教程要紧，今天晚上还要和天霸去吃烧烤勒，呵呵<br>马上就是提交分数了，<br>目标页面是<a href="http://hobby.qzone.qq.com/cgi-bin/game/play" target="_blank">http://hobby.qzone.qq.com/cgi-bin/game/play</a><wbr />，但是需要获取个人信息，才能完成提交，不然会有以下错误信息：{c701: {type: 701, msg: &quot;检测到系统速率异常，将不能提交分数！&quot;}, c901: {type: 901, msg: &quot;检测到当前环境为本地环境,以模拟方式运行.&quot;}, c1000: {type: 1000, msg: &quot;最终游戏分数提交成功!&quot;}, c1000: {type: 1001, msg: &quot;最终游戏分数提交失败!&quot;}, c1002: {type: 1002, msg: &quot;游戏授权成功,可以开始游戏!&quot;}, c1003: {type: 1003, msg: &quot;自动分数提交!&quot;}, c1004: {type: 1004, msg: &quot;获取游戏分数出错!&quot;}, c1005: {type: 1005, msg: &quot;提交当前阶段游戏分数,注意当前以模拟方式运行!未发送至服务器!&quot;}, c1006: {type: 1006, msg: &quot;获取制定游戏分数错误!&quot;}<br>所以，后面破解Mian.js 哎,TX的ajax。。。翻回去看falsh源码，。。。ok！<br>破解完成。，帖一段短短的代码大家就明白了<br>var getURL=“http://hobby.qzone.qq.com/cgi-bin/game/play&quot;;<br> var mm=new Gajax();<br>  mm.url=getURL;<br>  mm.async=true;<br>  mm.addsendlist(&quot;act&quot;,&quot;get&quot;);<br>  mm.addsendlist(&quot;pid&quot;,$pid());<br>  mm.oncomplete=function(){<br>   var rs=JSONDATA(mm.result.text);<br>   mm.close();<br>   if(rs.key){<br>    var qq=rs.uin;<br>    var key=rs.key;<br>    postKey(getPostKey(key,Myscore));<br>   }else{<br>     alert('你可能未登录');<br>   }<br>  }<br>-------------------var postURL=http://hobby.qzone.qq.com/cgi-bin/game/play&quot;;<br> var mm=new Gajax();<br>  mm.async=true;<br>  mm.url=postURL;<br>  mm.addsendlist(&quot;key&quot;,mykey);<br>  mm.addsendlist(&quot;score&quot;,Myscore);<br>  mm.addsendlist(&quot;act&quot;,&quot;set&quot;);<br>  mm.addsendlist(&quot;pid&quot;,$pid());<br>  mm.oncomplete=function(){<br>   var rs=JSONDATA(mm.result.text);<br>   mm.close();<br>  }<br>  mm.doForm(true);<br>就这样了，准备吃烧烤去了，没咋发布过教程，有点不明不白的，忍了，有事密我就是的，有时间了再补充，写的匆忙完了，发表了<br> <br> <br> <!--v:3.2--> ]]></description>
<category><![CDATA[电脑编程]]></category>
<author><![CDATA[236540107@qq.com(ifree       )]]></author>
<comments>http://236540107.qzone.qq.com/blog/1252057173#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Fri, 04 Sep 2009 09:39:33 GMT</pubDate>
<guid>http://236540107.qzone.qq.com/blog/1252057173</guid>
</item>

<item>
<title><![CDATA[101个Google技巧 - Google技巧的终极收集]]></title>
<link>http://236540107.qzone.qq.com/blog/1251913007</link>
<description><![CDATA[<span style="font-weight:bold"><wbr />感谢Gfan的投递</span><wbr /><br>   1.  info:site_name 这个修饰语可以返回关于某特定页面的信息.<br>   2. 同样的,在普通搜索后点击&quot;相似网页&quot;可以链接到Google认为相似的页面结果.<br>   3. 如果只想搜索某一个风址里的内容,可能用site: 来实现,比如说search tips site:www.techradar.com.   4. 上述技巧通过像www.dmoz.org这样的目录网站并动态地生成网址.<br>   5. 也可直接进入Google Directory这样的人工挑选出来的数量有限的数据库网站,网址是www.direcory.google.com.<br>   6. intitle和inurl这样的布尔运算符像OR一样在Google Directory中同样适用.<br>   7. 当你用Google图片搜索时,用site:的修饰语可以只搜索某一个网站内的图片,比如 dvd recorder site:www.amazon.co.uk.<br>   8. 同样的,用&quot;site:.com&quot;只会返回带有.com域名后缀网站里的结果.<br>   9. Google新闻(news.google.com)有他自己的布尔运算符.例如“intext” 只会从一条新闻的主体内容里查询结果.<br>  10. 在Google新闻里如果你用“source:”这个运算符,你可以得到特定的新闻存档.比如:heather mills source:daily_mail<br>  11. 通过&quot;location:&quot;过滤器你可以等到特定国家的新闻,比如 location:uk<br>  12. 同样的Google博客搜索(blogsearch.google.com)也有它自己的句法.你可以搜索某篇日志的标题,比如 &quot;inblogtitle:&lt;keword&gt;&quot;<br>  13. Google的普通搜索也可以确实也可以得到精确的结果,不如用&quot;movie:&lt;name of film&gt;&quot; 来寻找电影评论.<br>  14. “film:”修饰语效果也一样.<br>  15. 在搜索框里输入上映时间,Google会提示你提交你的邮编,然后Google就会告诉你什么时候什么地方将会有好戏上演.<br>  16. 如果想要一个专门的电影搜索页面,可以去www.google.co.uk/movies<br>  17. 如果你圈选了“记住地点”后,下次你查询电影放映时间只需要输入电影名字就够了.<br>  18. Google确实在电影方面的搜索上下了些功夫.比如在搜索框中输入“director:&lt;电影名&gt;”你将得到什么结果?你肯定猜到了吧.<br>  19. 如果想得到演员名单,如需输入“cast:name_of_film”<br>  20. 在乐队名、歌曲名或者专辑名前加上“music:”可以得到相关的音乐信息和评论.<br>  21. 如果你在搜索框里输入“weather London”便可以得到伦敦最近四天完整的天气预报.<br>  22. Google也内置了词典,在搜索框里用&quot;define:the_word&quot;试试.<br>  23. Goolge保存了网站过去的内容.你可以直接搜索某个页面在Google服务器里的缓存,相关句法是“keyword cache:site_url”<br>  24. 相应的,直接在搜索框里输入“cache:site_url”可以直接进入缓存页面.<br>  25. 如果你手边没有计算器,只要记住Google同样内置了这么一个功能.输入“12*15”然后点击搜索试试.<br>  26. Google的内置计算器不但可以转换尺寸还可以理解自然语言.搜索一下“14 stones in kilos”<br>  27. 汇率转换也同样适用,试试“200 pounds in euros”<br>  28. 如果你知道某货币的代码,将得到更加可靠的结果,例如&quot;200 GBR in EUR&quot;<br>  29. 温度呢?Google也没有放过,输入“98 f to c”便可以把华氏转换为摄氏.<br>  30. 想知道Google到底有多聪明呢?输入“2476 in roman numerals”然后点击“搜索”就知道了.<br>  31. 你也可以保存你的Google使用习惯偏好,只需要在www.google.com/account上注册一个帐号便可.<br>  32. 一旦有了Google帐号,不旦可以免费获得一个Gmail帐号,最主要的是可以畅通无阻地遨游于Google的世界.<br>  33. 登陆你的Google帐户,通过“iGoogle”你还可以个性化你的Google主页.<br>  34. 在“iGoogle”上点击&quot;Add a Tab&quot;来添加多个内容模块,Google会根据你添加的甩有模块来自适应整个页面.<br>  35. &quot;iGoogle&quot;允许你为主页更换模板,点击&quot;Select Theme&quot;便可改变现有的默认主题.<br>  36. 有一些&quot;iGoogle&quot;主题会随着时间的改变而改变,比如&quot;Sweet Dreams&quot;就是一个随着白天到夜晚的更迭而改变的一款主题.<br>  37. 点击&quot;Try something new&quot; 下面的&quot;More&quot; 就可以看到一个更加完整的Google网站列表和一些新的功能.<br>  38. &quot;Custom Search&quot;帮助你为你自己的网站建立一个Google牌的搜索引擎.<br>  39. 另外,那张列表还忘掉了一个很有用的服务“Personalised Search&quot;,不过你可以通过访问www.google.com/psearch来使用它.(一个保存你搜索记录的服务——译者注)<br>  40. 这个页面列出了你最近的搜索,并按特定分类来区分他们,点击&quot;pause&quot; 就可以阻止Google记录你的搜索历史.<br>  41. 点击&quot;Trends&quot;可以看到你最访问的网站,你最搜索最多的条目以及最常点击的链接.<br>  42. 个性化搜索同样包括了一个书签服务,它帮助你在线保存书签并可以在任何地方获取他们.<br>  43. 更方便的是,你可以在&quot;iGoogle&quot;上添加一个书签模块来添加或访问它们.<br>  44. 你知道你还可以搜索Google返回的结果么?滑到搜索结果页面底部便可以找到那链接.<br>  45. 在你的查询后面附加你的邮编便可以搜索本地信息.<br>  46. 找地图?只需要在搜索关键词后面多写一个&quot;map&quot;,比如“Leeds map”<br>  47. Google搜索图片(这里指直接在Google首页而不是Google Map页面,译者注)非常简单,只要你在关键词后而多写个“image”,你就会在搜索结果的顶部看到相关的图片结果.<br>  48. 神奇的是Google图片搜索可以识别人脸,在浏览器地址栏搜索结果页面网址后面添加“&amp;imgtype=face” 确定后Google会过滤掉所有不是人的图片.<br>  49. 想关注股市行情?只需要在&quot;stock:&quot;后面填上公司的股票代码便可以得到从Google财经返回的结果.<br>  50. 在Google的搜索框中输入航空公司或者航班号可以获得相关的航班信息.<br>  51. 现在几点了?在地点前面加上“time”可以得到任务地方的时间.<br>  52. 你也许已经注意到了在输入关键词时Google会交替提示你的拼写,那内置的拼写检查在起作用.<br>  53. 你可以在关键词前加上&quot;spell:&quot;来直接调用Google的拼写检查功能.<br>  54. 点击&quot;I'm Feeling Lucky&quot; (手气不错)可以直接访问关键词搜索第一个结果的网页.<br>  55. 输入基于统计的查询关键词,比如population of Britain,在结果顶部Google会告诉你它的答案.<br>  56. 如果你看到的搜索有非英文结果,点击&quot;Translate this Page&quot; 可以看到由Google帮你翻译的英文内容.<br>  57. 你也可以搜索国外网站的内容,点击语言工具,然后选择你想要Google帮你翻译查询的国家.<br>  58. 语言工具的另一个特色是可以帮你翻译一些可自由剪贴的文本字块.<br>  59. 这里也有一个区域,你可以直接输入网址,并让Google翻译成你想要的语言.<br>  60. 在“语言工具”链接上面你可以看到一个“使用偏好”的链接,这是一个包含了一些私密设置的页面.<br>  61. 你可以明确地告诉Google你希望返回结果的语言,可根据你的喜好进行多选.<br>  62. Google的安全搜索可以保护你免受色情内容的侵犯.你可以选择性的让过滤系统更加严格或者把它完全地关闭.<br>  63. 在使用偏好里,你可以改变Google搜索单页显示结果的结果数,默认为10.<br>  64. 你也可以设置为在新窗口打开Google的搜索结果.<br>  65. 想知道他人在搜索的内容或者提高你自己网站的Pagerank值(Google自行开发的网页质量等级排名评估算法,Pagerank值越高的网页在搜索结果里越靠前,译者注)?去www.google.com/zeitgeist看看.<br>  66. 另一个强大的实验性功能可以在www.google.com/trends找到,你可以知道哪些是热门搜索条目.<br>  67. 在Google趋势搜索框里输入以逗号间隔的多个关键词,可以对比他们的搜索表现.<br>  68. 想用克林贡语搜索?去www.google.com/intl/xx-klingon就可以了.<br>  69. 也许你提线木偶里的瑞典厨师是你的榜样?点击www.google.com/intl/xx-bork看看.<br>  70. 在搜索框里输入“answer to life, the universe and everything”,你肯定会被结果吓一跳.<br>  71. Google还可以告诉你独角兽有多少只角,(够搞笑吧).输入“number of horns on a unicorn”看看.<br><br>   1. 更加全面地用Google搜索的最好方式是点击高级搜索.<br>   2. 它可以让你搜索更加精准的词组,“所有词组”或者是适当的搜索框里输入词组的某一个特定关键词.<br>   3. 在高级搜索里你依然可以自定义在一张页面上展示多少个搜索结果,你所寻找的信息语言和文件格式.<br>   4. “搜索以下网站或网域”可以让你通过输入一个顶级域名(如.co.uk)来限定搜索结果.<br>   5. 你也可以点击“日期、使用权限、数字范围和更多”的链接以获取更高级的功能.(Google中文直接分条在页面展示.)<br>   6. 保存设置,这些高级功能大多也可以在Google首页的搜索框中通过命令行参数来实现<br>   7. Google的主要搜索可以无形地用布尔结构“AND”来结合.你当输入smoke fire - 它表示寻找smoke AND fire.<br>   8. 要让Google搜索Smoke 或者fire,只需要输入smoke OR fire.<br>   9. 你也可以用 | 来代替OR.如:smoke | fire.<br>  10. 像AND 和 OR 这样的布尔结构对大小写非常敏感.他们必须是全部大写.<br>  11. 搜索专有名词,然后输入用括号括住的一个或者几个关键词.比如water (smoke OR fire)<br>  12. 寻找短语,可以把它们放在引号里.比如:&quot;there's no smoke without fire&quot;.<br>  13. 同义搜索来寻找那些类似的信息,只须在你的关键词臆加一根波浪线,比如:~eggplant.<br>  14. 用减号来排除关键词,如:new pram -ebay  可以让搜索结果排除来自Ebay的婴儿车信息.<br>  15. 像 I, and, then ,if 这类普通词语是要被Google 忽略的.他们被称作停滞词语.<br>  16. 而加号却可以让这些停滞词语给包含进来,比如:fish +and chips.<br>  17. 如果一个停滞词语被包含在那些作为短语的引用标记中间的句子中时,这些词语是被Google允许的.<br>  18. 你也可以要求Google进行简省搜索,试一下:Christopher Columbus discovered *<br>  19. 用数字范围功能来搜索数字范围.例如:搜索价位在300英到500英磅之间的索尼电视可以用以下字串:Sony TV &amp;pound;300..&amp;pound;500.<br>  20. 通过高级搜索Google认可13种主要文件格式,其中包括Office, Lotus, PostScript, Shockwave Flash 和text.<br>  21. 搜索这些文件只需直接使用修饰符 filetype:[文件扩展名].例如:soccer filetype:pdf.<br>  22. 要排除整个文件格式,只需使用以前我们排除关键词时使用的相同布尔句法:橄榄球 -filetype:doc<br>  23. 事实上,只要你的语法正确,你可以混合使用任何布尔搜索运算符.举个例子便是:&quot;sausage and mash&quot; -onions filetype:doc<br>  24. Google也有很多功能强大却隐藏着的搜索参数,例如“intitle” 仅仅只会搜索网页标题(titles).你可以用这个例子试一试:intitle:网页设计<br>  25. 如果你只是寻找文件而不是网页,只需用index of 代替intitle:参数.它可以帮助你寻找网络和FTP目录.<br>  26. inurl这个修饰语只会搜索网页的网址,不妨用这个例子试一试 inurl:spices<br>  27. 通过 inurl:vien/view.shtml 你可以找到在线的网络摄像头.<br>  28. inanchor这个修饰语非常特别,它仅仅只会寻找那些作为超链接的文本.<br>  29. 想知道有多少链接指向一个网站.可以试试这个语法:link:网址 - 比如link:www.mozilla.org<br>  30. 同样的,你也可以通过 related:修饰语来找到Google认为相似的内容.比如: related:www.microsoft.com <br> <!--v:3.2--> ]]></description>
<category><![CDATA[电脑编程]]></category>
<author><![CDATA[236540107@qq.com(ifree       )]]></author>
<comments>http://236540107.qzone.qq.com/blog/1251913007#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Wed, 02 Sep 2009 17:36:47 GMT</pubDate>
<guid>http://236540107.qzone.qq.com/blog/1251913007</guid>
</item>

<item>
<title><![CDATA[exists 相关]]></title>
<link>http://236540107.qzone.qq.com/blog/1251769170</link>
<description><![CDATA[总结点t-sql中exists 的相关知识，有点乱，忍了，大家可以参考下<br>前两天一直不是很明白exists的用法..书上写的就几句话.网上的我找到的都是一个样SQL Server里的帮助文档,看的好郁闷,现在弄明白了.拿经验和大家分享一下.<br>exists(包括not exists)子查询<br><br>通过这几天的感觉.exists应该是这样的<br><br>select distinct 姓名 from xs<br>where not exists (<br>select * from kc<br>where not exists (<br>select * from xs_kc<br>where 学号=xs.学号 and 课程号=kc.课程号<br>)<br><br>)<br>go<br><br>拿这个来说吧:<br>系统会把最外层的查询xs里的数据一行一行的做里层的子查询.<br><br>注意:中间的exists语句只做出对上一层的返回true或false,因为,查询的条件都在where 学号=xs.学号 and 课程号=kc.课程号这句话里.每一个exists都会有一行值.它只是告诉一层,最外层的查询条件在这里成立或都不成立,返回的时候值也一样回返回上去.直到最高层的时候如果是true(真)就返回到结果集.为false(假)丢弃<br><br>where not exists<br>select * from xs_kc<br>where 学号=xs.学号 and 课程号=kc.课程号<br>这个exists就是告诉上一层.这一行语句在我这里不成立.因为他不是最高层.所以还要继续向上返回)<br><br>select distinct 姓名 from xs<br>where not exists (这里的exists语句收到上一个为false的值.他在判断一下.结果就是为true(成立),由于是最高层所以就会把这行的结果(这里指的是查询条件)返回到结果集)<br><br>我感觉几个重要的点:<br>1:最里层要用到的醒询条件的表比如:xs.学号、kc.课程号等都要在前面的时候说明一下select * from kc,select distinct 姓名 from xs<br>2:不要在太注意中间的exists语句.<br>3:把exists和not exists嵌套时的返回值弄明白<br>----------------------------------------------------------------------<br>sql中exists用具体用法 <br>exists(包括not exists)子查询 <br>exists应该是这样的 select distinct 姓名 from xs <br>where not exists ( <br>select * from kc <br>where not exists ( <br>select * from xs_kc <br>where 学号=xs.学号 and 课程号=kc.课程号 <br>) <br> <br>) <br>go <br> <br>拿这个来说吧: <br>系统会把最外层的查询xs里的数据一行一行的做里层的子查询. <br> <br>注意:中间的exists语句只做出对上一层的返回true或false,因为,查询的条件都在where 学号=xs.学号 and 课程号=kc.课程号这句话里.每一个exists都会有一行值.它只是告诉一层,最外层的查询条件在这里成立或都不成立,返回的时候值也一样回返回上去.直到最高层的时候如果是true(真)就返回到结果集.为false(假)丢弃 <br> <br>where not exists <br>select * from xs_kc <br>where 学号=xs.学号 and 课程号=kc.课程号 <br>这个exists就是告诉上一层.这一行语句在我这里不成立.因为他不是最高层.所以还要继续向上返回) <br> <br>select distinct 姓名 from xs <br>where not exists (这里的exists语句收到上一个为false的值.他在判断一下.结果就是为true(成立),由于是最高层所以就会把这行的结果(这里指的是查询条件)返回到结果集) <br>------------------------------------------------------------------------------------------------------------------<br>exists （sql 返回结果集为真） <br>not exists (sql 不返回结果集为真） <br>如下： <br>表A <br>ID NAME <br>1    A1 <br>2    A2 <br>3  A3 <br><br>表B <br>ID AID NAME <br>1    1 B1 <br>2    2 B2 <br>3    2 B3 <br><br>表A和表B是１对多的关系 A.ID =&gt; B.AID <br><br>SELECT ID,NAME FROM A WHERE EXIST (SELECT * FROM B WHERE A.ID=B.AID) <br>执行结果为 <br>1 A1 <br>2 A2 <br>原因可以按照如下分析 <br>SELECT ID,NAME FROM A WHERE EXISTS (SELECT * FROM B WHERE B.AID=１) <br>---&gt;SELECT * FROM B WHERE B.AID=１有值返回真所以有数据 <br><br>SELECT ID,NAME FROM A WHERE EXISTS (SELECT * FROM B WHERE B.AID=2) <br>---&gt;SELECT * FROM B WHERE B.AID=２有值返回真所以有数据 <br><br>SELECT ID,NAME FROM A WHERE EXISTS (SELECT * FROM B WHERE B.AID=3) <br>---&gt;SELECT * FROM B WHERE B.AID=３无值返回真所以没有数据 <br><br>NOT EXISTS 就是反过来 <br>SELECT ID,NAME FROM A WHERE　NOT EXIST (SELECT * FROM B WHERE A.ID=B.AID) <br>执行结果为 <br>3 A3 <br>=========================================================================== <br>EXISTS = IN,意思相同不过语法上有点点区别，好像使用IN效率要差点，应该是不会执行索引的原因 <br>SELECT ID,NAME FROM A　 WHERE　ID IN (SELECT AID FROM B) <br><br>NOT EXISTS = NOT IN ,意思相同不过语法上有点点区别 <br>SELECT ID,NAME FROM A WHERE　ID　NOT IN (SELECT AID FROM B) <br><br><br>下面是普通的用法： <br><br>SQL中IN,NOT IN,EXISTS,NOT EXISTS的用法和差别: <br>　　IN:确定给定的值是否与子查询或列表中的值相匹配。 <br>　　IN 关键字使您得以选择与列表中的任意一个值匹配的行。 <br>　　当要获得居住在 California、Indiana 或 Maryland 州的所有作者的姓名和州的列表时，就需要下列查询： <br>　　SELECT ProductID, ProductName FROM Northwind.dbo.Products WHERE CategoryID = 1 OR CategoryID = 4 OR CategoryID = 5 <br>　　然而，如果使用 IN，少键入一些字符也可以得到同样的结果： <br>　　SELECT ProductID, ProductName FROM Northwind.dbo.Products WHERE CategoryID IN (1, 4, 5) <br>　　IN 关键字之后的项目必须用逗号隔开，并且括在括号中。 <br>　　下列查询在 titleauthor 表中查找在任一种书中得到的版税少于 50% 的所有作者的 au_id，然后从 authors 表中选择 au_id 与 <br>　　titleauthor 查询结果匹配的所有作者的姓名： <br>　　SELECT au_lname, au_fname FROM authors WHERE au_id IN (SELECT au_id FROM titleauthor WHERE royaltyper &lt;50) <br>　　结果显示有一些作者属于少于 50% 的一类。 <br>　　NOT IN:通过 NOT IN 关键字引入的子查询也返回一列零值或更多值。 <br>　　以下查询查找没有出版过商业书籍的出版商的名称。 <br>　　SELECT pub_name FROM publishers WHERE pub_id NOT IN (SELECT pub_id FROM titles WHERE type = 'business') <br>　　使用 EXISTS 和 NOT EXISTS 引入的子查询可用于两种集合原理的操作：交集与差集。 <br>      两个集合的交集包含同时属于两个原集合的所有元素。 <br>　　差集包含只属于两个集合中的第一个集合的元素。 <br>　　EXISTS:指定一个子查询，检测行的存在。 <br>　　本示例所示查询查找由位于以字母 B 开头的城市中的任一出版商出版的书名： <br>　　SELECT DISTINCT pub_name FROM publishers WHERE EXISTS (SELECT * FROM titles WHERE pub_id = publishers.pub_id AND type = <br>　　'business') <br>　　SELECT distinct pub_name FROM publishers WHERE pub_id IN (SELECT pub_id FROM titles WHERE type = 'business') <br>　　两者的区别: <br>　　EXISTS:后面可以是整句的查询语句如:SELECT * FROM titles <br>　　IN:后面只能是对单列:SELECT pub_id FROM titles <br>　　NOT EXISTS: <br>　　例如，要查找不出版商业书籍的出版商的名称： <br>　　SELECT pub_name FROM publishers WHERE NOT EXISTS (SELECT * FROM titles WHERE pub_id = publishers.pub_id AND type = <br>　　'business') <br>　　下面的查询查找已经不销售的书的名称: <br>　　SELECT title FROM titles WHERE NOT EXISTS (SELECT title_id FROM sales WHERE title_id = titles.title_id) <br><br>语法 <br><br>EXISTS subquery <br>参数 <br>subquery:是一个受限的 SELECT 语句 (不允许有 COMPUTE 子句和 INTO 关键字)。有关更多信息，请参见 SELECT 中有关子查询的讨论。 <br><br>结果类型:Boolean <br><br><br>结果值:如果子查询包含行，则返回 TRUE。 <br><br><br>示例 <br>A. 在子查询中使用 NULL 仍然返回结果集 <br><br>这个例子在子查询中指定 NULL，并返回结果集，通过使用 EXISTS 仍取值为 TRUE。 <br><br>USE Northwind <br>GO <br>SELECT CategoryName <br>FROM Categories <br>WHERE EXISTS (SELECT NULL) <br>ORDER BY CategoryName ASC <br>GO <br><br>B. 比较使用 EXISTS 和 IN 的查询 <br><br>这个例子比较了两个语义类似的查询。第一个查询使用 EXISTS 而第二个查询使用 IN。注意两个查询返回相同的信息。 <br><br>USE pubs <br>GO <br>SELECT DISTINCT pub_name <br>FROM publishers <br>WHERE EXISTS <br>    (SELECT * <br>    FROM titles <br>    WHERE pub_id = publishers.pub_id <br>    AND type = \'business\') <br>GO <br><br>-- Or, using the IN clause: <br><br>USE pubs <br>GO <br>SELECT distinct pub_name <br>FROM publishers <br>WHERE pub_id IN <br>    (SELECT pub_id <br>    FROM titles <br>    WHERE type = \'business\') <br>GO <br><br><br>下面是任一查询的结果集： <br><br>pub_name                                <br>---------------------------------------- <br>Algodata Infosystems                    <br>New Moon Books                          <br><br>C.比较使用 EXISTS 和 = ANY 的查询 <br><br>本示例显示查找与出版商住在同一城市中的作者的两种查询方法：第一种方法使用 = ANY，第二种方法使用 EXISTS。注意这两种方法返回相同的信息。 <br><br>USE pubs <br>GO <br>SELECT au_lname, au_fname <br>FROM authors <br>WHERE exists <br>    (SELECT * <br>    FROM publishers <br>    WHERE authors.city = publishers.city) <br>GO <br><br>-- Or, using = ANY <br><br>USE pubs <br>GO <br>SELECT au_lname, au_fname <br>FROM authors <br>WHERE city = ANY <br>    (SELECT city <br>    FROM publishers) <br>GO <br><br><br>D.比较使用 EXISTS 和 IN 的查询 <br><br>本示例所示查询查找由位于以字母 B 开头的城市中的任一出版商出版的书名： <br><br>USE pubs <br>GO <br>SELECT title <br>FROM titles <br>WHERE EXISTS <br>    (SELECT * <br>    FROM publishers <br>    WHERE pub_id = titles.pub_id <br>    AND city LIKE \'B%\') <br>GO <br><br>-- Or, using IN: <br><br>USE pubs <br>GO <br>SELECT title <br>FROM titles <br>WHERE pub_id IN <br>    (SELECT pub_id <br>    FROM publishers <br>    WHERE city LIKE \'B%\') <br>GO <br><br><br>E. 使用 NOT EXISTS <br><br>NOT EXISTS 的作用与 EXISTS 正相反。如果子查询没有返回行，则满足 NOT EXISTS 中的 WHERE 子句。本示例查找不出版商业书籍的出版商的名称： <br><br>USE pubs <br>GO <br>SELECT pub_name <br>FROM publishers <br>WHERE NOT EXISTS <br>    (SELECT * <br>    FROM titles <br>    WHERE pub_id = publishers.pub_id <br>    AND type = \'business\') <br>ORDER BY pub_name <br>GO ----------------------------------------------------------- <!--v:3.2--> ]]></description>
<category><![CDATA[电脑编程]]></category>
<author><![CDATA[236540107@qq.com(ifree       )]]></author>
<comments>http://236540107.qzone.qq.com/blog/1251769170#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Tue, 01 Sep 2009 01:39:30 GMT</pubDate>
<guid>http://236540107.qzone.qq.com/blog/1251769170</guid>
</item>

<item>
<title><![CDATA[经典算法详解，值得收藏]]></title>
<link>http://236540107.qzone.qq.com/blog/1251268469</link>
<description><![CDATA[ <br><span style="font-weight:bold"><wbr />请编写一个函数实现顺序线性表的原地置逆，即利用原表的存储空间。  </span><wbr /><br>要将该表逆置，可以将表中的开始结点与终端结点互换，第二个结点与倒数第二个结点互换，如此反复，就可将整个表逆置了。算法如下：    <br>算法如下:<br>#define ListSize 100// 假定表空间大小为100<br>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>void Error(char * message)<br>{fprintf(stderr,&quot;错误:%s\n&quot;,message);<br>exit(1);<br>}       //从0开始计，表空间大小应为101了<br>typedef  int Datatype ;//假定Datatype的类型为int型<br>typedef  struct{<br>Datatype  data[ListSize];// 向量data用于存放表结点<br>int length; //  当前的表长度<br>} Seqlist;<br>//以上为定义表结构<br>void  ReverseList(  Seqlist *L)<br>{<br>    Datatype   t ; //设置临时空间用于存放data<br>    int i;<br>    for ( i=0 ; i &lt; L-&gt;length/2 ; i++)<br>        {   t = L-&gt;data<span style="font-style:italic"><wbr />; //交换数据<br>            L -&gt; data[ i ]  = L -&gt; data[ L -&gt; length - 1 - i ]  ;<br>            L -&gt; data[ L -&gt; length - 1 - i ] = t  ;<br>        }<br>}<br><span style="font-weight:bold"><wbr />请编写一个函数实现单链表的原地置逆，即利用原表的存储空间。  </span><wbr /><br>也是可以用交换数据的方式来达到逆置的目的，但是由于是单链表，数据的存取不是随机的，因此算法效率太低，我们可以利用指针的指向转换来达到表逆置的目的。<br>算法如下:<br>#define ListSize 100// 假定表空间大小为100<br>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>void Error(char * message)<br>{<br>fprintf(stderr,&quot;错误:%s\n&quot;,message);<br>exit(1);<br>}//从0开始计，表空间大小应为101了<br>typedef  int Datatype ;//假定Datatype的类型为int型<br>typedef  struct{<br>Datatype  data[ListSize];// 向量data用于存放表结点<br>int length; //  当前的表长度<br>} Seqlist;<br>//以上为定义表结构<br>LinkList  ReverseList( LinkList  head  )<br>{                               // 将head 所指的单链表逆置<br>    ListNode *p  ,*q ;//设置两个临时指针变量<br>        if( head-&gt;next &amp;&amp; head-&gt;next-&gt;next)<br>    {                           //当链表不是空表或单结点时<br>        p=head-&gt;next;<br>        q=p-&gt;next;<br>        p -&gt; next=NULL; //将开始结点变成终端结点<br>        while (q)<br>        {                       //每次循环将后一个结点变成开始结点<br>            p=q;    <br>            q=q-&gt;next ;<br>            p-&gt;next = head-&gt; next  ;<br>            head-&gt;next = p;<br>        }<br>        return head;<br>    }<br>    return head;    //如是空表或单结点表，直接返回head<br>}<br><span style="font-weight:bold"><wbr />设线性表的n个结点定义为(a0,a1,...an-1)，重写顺序表上实现的插入和删除算法：InsertList 和DeleteList.</span><wbr /><br>算法如下:<br>#define ListSize 100// 假定表空间大小为100<br>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>void Error(char * message)<br>{<br>fprintf(stderr,&quot;错误:%s\n&quot;,message);<br>exit(1);<br>}//从0开始计，表空间大小应为101了<br>typedef  int Datatype ;//假定Datatype的类型为int型<br>typedef  struct{<br>Datatype  data[ListSize];// 向量data用于存放表结点<br>int length; //  当前的表长度<br>} Seqlist;<br>//以上为定义表结构<br>//------------以下为要求算法----------<br>void InsertList ( Seqlist *L, Datatype x, int i)<br>{//将新结点x插入L所指的顺序表的第i个结点ai的位置上<br>int j;<br>if ( i &lt; 0 || i &gt; L -&gt; length )<br>Error(&quot;position error&quot;);// 非法位置，退出<br>if ( L-&gt;length&gt;=ListSize )<br>Error(&quot;overflow&quot;);<br> for ( j=L-&gt;length-1 ; j &gt;= i ; j --)<br>L-&gt;data[j+1]=L-&gt;data [j];<br>L-&gt;data<span style="font-style:italic"><wbr />=x ;<br>L-&gt;length++ ;<br>}<br> <br>void DeleteList ( Seqlist *L, int i )<br>{// 从L所指的顺序表中删除第i个结点ai<br>int j;<br> if ( i&lt; 0 || i &gt; L-&gt; length-1)<br>Error( &quot; position error&quot; ) ;<br> for ( j = i+1 ; j &lt; L-&gt; length ; j++ )<br>    L-&gt;data [ j-1 ]=L-&gt;data [ j]; // 结点前移<br>L-&gt; length-- ; //表长减小<br>}<br>//===========以下为验证算法而加=======<br>void Initlist(Seqlist *L)<br>{<br>    L-&gt;length=0;<br>}<br>void main()<br>{<br>     Seqlist *SEQA=new Seqlist;<br>     Initlist(SEQA);<br>     int i;<br>     for (i=0;i&lt;ListSize;i++)<br>     {  <br>         InsertList (SEQA,i,i);<br>         printf(&quot;%d\n&quot;,SEQA-&gt;data<span style="font-style:italic"><wbr />);<br>     }<br>         DeleteList (SEQA,99);<br>     for (i=0;i&lt;ListSize-1;i++)<br>     {<br>    printf(&quot;%d\n&quot;,SEQA-&gt;data<span style="font-style:italic"><wbr />);<br>    }<br>}<br><span style="font-weight:bold"><wbr /><span style="font-family:'宋体';line-height:1.8em;">设顺序表L是一个递增有序表，试写一算法，将x插入L中，并使L仍是一个有序表。</span><wbr /></span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">解：因已知顺序表L是递增有序表，所以只要从头找起找到第一个比它大(或相等)的结点数据，把x插入到这个数所在的位置就是了。</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">算法如下：</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">void InsertIncreaseList( Seqlist *L , Datatype x )<br>{<br>int i;<br>for ( i=0 ; i &lt; L -&gt; length &amp;&amp; L-&gt;data[ i ] &lt; x ; i++) ;</span><wbr /><span style="font-family:'宋体';line-height:1.8em;"> // 查找并比较,分号不能少</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">InsertList ( L </span><wbr /><span style="font-family:'宋体';line-height:1.8em;">，x , i );             // 调用顺序表插入函数</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">}</span><wbr /><span style="font-weight:bold"><wbr /><span style="font-family:'宋体';line-height:1.8em;">设顺序表L是一个递减有序表，试写一算法，将x插入其后仍保持L的有序性。</span><wbr /></span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">解：与上题相类似，只要从头找到第一个比x小(或相等)的结点数据，在这个位置插入就可以了。</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">算法如下：</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">void InsertDecreaseList( Seqlist *L, Datatype x )<br>{<br>int i;<br>for (i=0; i&lt; L -&gt; length &amp;&amp; L-&gt; data<span style="font-style:italic"><wbr /> &gt; x ; i++) ; //</span><wbr /><span style="font-family:'宋体';line-height:1.8em;">查找</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">InsertList ( L , x , i ); // </span><wbr /><span style="font-family:'宋体';line-height:1.8em;">调用顺序表插入函数</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">}</span><wbr /><span style="font-weight:bold"><wbr /><span style="font-family:'宋体';line-height:1.8em;">写一算法在单链表上实现线性表的ListLength(L)运算。</span><wbr /></span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">求单链表长只能用遍历的方法了，从头数到尾，总能数出来吧。</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">算法如下：</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">int ListLength ( LinkList L )<br>{<br>int len=0 ;<br>ListNode *p;<br>p=L; //</span><wbr /><span style="font-family:'宋体';line-height:1.8em;">设该表有头结点</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">while ( p-&gt;next )<br>{<br>p=p-&gt;next;<br>len++;<br>}<br>return len;<br>}</span><wbr /><span style="font-weight:bold"><wbr /><span style="font-family:'宋体';line-height:1.8em;">已知L1和L2分别指向两个单链表的头结点，且已知其长度分别为m和n。试写一算法将这两个链表连接在一起，请分析你的算法的时间复杂度。</span><wbr /></span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">算法如下:</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">LinkList Link( LinkList L1 , LinkList L2 )<br>{<br>//</span><wbr /><span style="font-family:'宋体';line-height:1.8em;">将两个单链表连接在一起</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">ListNode *p , *q ;<br>p=L1;<br>q=L2;<br>while ( p-&gt;next ) p=p-&gt;next; //</span><wbr /><span style="font-family:'宋体';line-height:1.8em;">查找终端结点</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">p-&gt;next = q-&gt;next ; //</span><wbr /><span style="font-family:'宋体';line-height:1.8em;">将L2的开始结点链接在L1之后</span><wbr /><br><span style="font-family:'宋体';line-height:1.8em;">return L1 ;<br>}</span><wbr /><span style="font-family:'宋体';line-height:1.8em;">本算法的主要操作时间花费在查找L1的终端结点上，与L2的长度无关，所以本算的法时间复杂度为：m+1=O(m)</span><wbr /><br><span style="font-weight:bold"><wbr /><span style="font-family:'宋体';line-height:1.8em;">设 A和B是两个单链表，其表中元素递增有序。试写一算法将A和B归并成一个按元素值递减有序的单链表C，并要求辅助空间为O(1)，请分析算法的时间复杂度。</span><wbr /></span><wbr /><br>解：要解这样的问题，我们首先想到的是拿链表中的元素一个个地与max和min比较，然后删除这个结点，其实因为已知其是有序链表，所以我们只要找到大于min的结点的直接前趋结点，再找到小于max的结点，然后一并把中间的全部摘掉就可以了。 <br>算法如下：<br>void DeleteList ( LinkList L, DataType min , DataType max )<br>{<br>  ListNode *p , *q , *h;<br>  p=L-&gt;next;<br>  while( p  &amp;&amp; p-&gt;data &lt;=min ) <br>  {       //找比min大的前一个元素位置<br>          q=p;<br>          p=p-&gt;next;<br>      <br>  }<br>          p=q;    //保存这个元素位置  <br>  while( q  &amp;&amp; q-&gt;data &lt; max ) //找比max小的最后一个元素位置<br>      {<br>           q=q-&gt;next;         <br>      }<br>      h=p-&gt;next;<br>      p-&gt;next=q;      //把断点链上<br>      free(h);            // 释放空间     <br>}<br><span style="font-weight:bold"><wbr />写一算法将单链表中值重复的结点删除，使所得的结果表中各结点值均不相同。</span><wbr /><br>解：本题可以这样考虑，先取开始结点中的值，将它与其后的所有结点值一一比较，发现相同的就删除掉，然后再取第二结点的值，重复上述过程直到最后一个结点。<br>第二种算法是将单链表按值的大小排序，排好后的结点按相同的删除。<br>（具体算法略。）<br><span style="font-weight:bold"><wbr />假设在长度大于1的单循环链表中，既无头结点也无头指针。s为指向链表中某个结点的指针，试编写算法删除结点*s的直接前趋结点。</span><wbr /><br>解：已知指向这个结点的指针是*s，那么要删除这个结点的直接前趋结点，就只要找到一个结点，它的指针域是指向*s的，把这个结点删除就可以了。<br>算法如下：<br>void DeleteNode( ListNode *s)<br>{<br>//删除单循环链表中指定结点的直接前趋结点<br>ListNode *p, *q;<br>p=s;<br>while( p-&gt;next-&gt;next!=s) <br>{<br>q=p; /<br>p=p-&gt;next;<br>}<br>q-&gt;next=s; //删除结点<br>free(p); //释放空间<br>}<br><span style="font-weight:bold"><wbr />已知由单链表表示的线性表中，含有三类字符的数据元素(如：字母字符、数字字符和其它字符)，试编写算法构造三个以循环链表表示的线性表，使每个表中只含同一类的字符，且利用原表中的结点空间作为这三个表的结点空间，头结点可另辟空间。</span><wbr /><br>解：要解决这样的问题，只要新建三个头结点，然后在原来的单链表中依次查询，找到一类字符结点时，就摘下此结点链接到相应头结点指明的新链表中就是了。<br>算法如下：<br>//设已建立三个带头结点的空循环链表A,B,C.<br>void DivideList( LinkList L, LinkList A, LinkList B, LinkList C)<br>{<br>  ListNode *p=L-&gt;next, *q;<br>  ListNode *a=A,<br>  ListNode  *b=B;<br>  ListNode  *c=C;<br>  while ( p )<br>  {<br>  if ( p-&gt;data&gt;='a' &amp;&amp;p-&gt;data&lt;='z'|| p-&gt;data&gt;='A' &amp;&amp;p-&gt;data&lt;='Z')<br>      {<br>          q=p;    //保存字母结点位置<br>          p=p-&gt;next;//指向下一结点<br>          a-&gt;next=q;//将字母结点链到A表中<br>          q-&gt;next=A;// 形成循环链表<br>          a=a-&gt;next; // 指向下一结点<br>      }<br>  else if( p-&gt;data&gt;='0' &amp;&amp; p-&gt;data&lt;='9')<br>      {   // 分出数字结点<br>          q=p;<br>          p=p-&gt;next;<br>          b-&gt;next=q;<br>          q-&gt;next=B;<br>          b=b-&gt;next;<br>      }<br>  else<br>       {  //分出其他字符结点<br>          q=p;<br>          p=p-&gt;next;<br>          c-&gt;next=q;<br>          q-&gt;next=C;<br>          c=c-&gt;next;<br>      }<br>  }<br>}<br><span style="font-weight:bold"><wbr />设有一个双链表，每个结点中除有prior、data和next三个域外，还有一个访问频度域freq，在链表被起用之前，其值均初始化为零。每当在链表进行一次LocateNode(L,s)运算时，令元素值为x的结点中freq域的值加1，并调整表中结点的次序，使其按访问频度的递减序排列，以便使频繁访问的结点总是靠近表头。试写一符合上述要求的LocateNode运算的算法。</span><wbr /><br>解：给freq域的值加1比较容易。就是每次加1后需进行排序比较麻烦。我们可以这样考虑，每次访问一个值为x的结点后，从表头开始找，根据结点中的freq值，如果找到比它小的结点，就把当前结点摘下，插入到freq值比它小的结点前面，就完成排序了。<br>算法如下：<br>void LocateNode(  LinkList  L,  DataType  x)<br>{<br>  ListNode  *p, *q;<br>  p=L-&gt;next;  //带有头结点<br>  q=L-&gt;next;<br>  while( p )<br>  {<br>      if( p-&gt;data!=x) p=p-&gt;next;<br>      else {<br>          p-&gt;freq++;<br>          break;<br>      }<br>  }<br>  while ( q )<br>  {<br>      if( q-&gt;freq &gt; p-&gt;freq) q=q-&gt;next;<br>      else {<br>          p-&gt;prior-&gt;next=p-&gt;next; //摘下当前结点<br>          p-&gt;next=q;       //插入到freq不大于它的结点前<br>          p-&gt;prior=q-&gt;p<br>      }<br>  }<br>} <!--v:3.2--> ]]></description>
<category><![CDATA[电脑编程]]></category>
<author><![CDATA[236540107@qq.com(ifree       )]]></author>
<comments>http://236540107.qzone.qq.com/blog/1251268469#comment</comments>
<qz:effect>134218240</qz:effect>
<pubDate>Wed, 26 Aug 2009 06:34:29 GMT</pubDate>
<guid>http://236540107.qzone.qq.com/blog/1251268469</guid>
</item>

</channel>
</rss>

