{"id":294,"date":"2009-11-21T16:03:22","date_gmt":"2009-11-21T08:03:22","guid":{"rendered":"http:\/\/115.29.108.60\/?p=294"},"modified":"2011-09-26T21:46:13","modified_gmt":"2011-09-26T13:46:13","slug":"lex-version0-2-class-heap","status":"publish","type":"post","link":"http:\/\/115.29.108.60\/?p=294","title":{"rendered":"Lex Version0.2 class Heap"},"content":{"rendered":"<p>#ifndef _HEAP_H_<br \/>\n#define _HEAP_H_<br \/>\nclass Heap {<br \/>\nprivate:<br \/>\n\u00a0int syn[100];\/\/\u5b58\u50a8\u8bcd\u6cd5\u5206\u6790\u540e\u7684\u7b26\u53f7\u8868<br \/>\n\u00a0int head, tail;\/\/\u6e38\u6807<br \/>\npublic:<br \/>\n\u00a0Heap();<br \/>\n\u00a0~Heap();<br \/>\n\u00a0int first();\/\/head=0\u5e76\u8fd4\u56de\u8be5syn\u3002-1\u8868\u793a\u5931\u8d25\u3002<br \/>\n\u00a0int prev();\/\/head\u524d\u79fb\u5e76\u8fd4\u56de\u8be5syn\u3002-1\u8868\u793a\u5931\u8d25\u3002<br \/>\n\u00a0int next();\/\/head\u540e\u79fb\u5e76\u8fd4\u56de\u8be5syn\u3002-1\u8868\u793a\u5931\u8d25\u3002<br \/>\n\u00a0bool append(int);\/\/\u52a0\u5165syn<br \/>\n};<br \/>\n#endif<\/p>\n<p>#include &#8220;StdAfx.h&#8221;<br \/>\n#include &#8220;Heap.h&#8221;<\/p>\n<p>Heap::Heap()<br \/>\n{<br \/>\n\u00a0for(int i = 0; i &lt; 100; i++)<br \/>\n\u00a0\u00a0syn[i] = -1;<br \/>\n\u00a0head = tail = 0;<br \/>\n}<\/p>\n<p>Heap::~Heap()<br \/>\n{<\/p>\n<p>}<\/p>\n<p>int Heap::first()<br \/>\n{<br \/>\n\u00a0head = 0;<br \/>\n\u00a0return syn[head];<br \/>\n}<\/p>\n<p>int Heap::prev()<br \/>\n{<br \/>\n\u00a0if(head == 0)<br \/>\n\u00a0\u00a0return -1;<br \/>\n\u00a0return syn[&#8211;head];<br \/>\n}<\/p>\n<p>int Heap::next()<br \/>\n{<br \/>\n\u00a0if(head == tail &#8211; 1)<br \/>\n\u00a0\u00a0return -1;<br \/>\n\u00a0return syn[++head];<br \/>\n}<\/p>\n<p>bool Heap::append(int tempsyn)<br \/>\n{<br \/>\n\u00a0if(tail &gt;= 200)<br \/>\n\u00a0\u00a0return false;<br \/>\n\u00a0syn[tail++] = tempsyn;<br \/>\n\u00a0return true;<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#ifndef _HEAP_H_ #define _HEAP_H_ class Heap { private: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,20],"tags":[],"class_list":["post-294","post","type-post","status-publish","format-standard","hentry","category-tools","category-cplusplus"],"_links":{"self":[{"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/posts\/294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/115.29.108.60\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=294"}],"version-history":[{"count":2,"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions"}],"predecessor-version":[{"id":890,"href":"http:\/\/115.29.108.60\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions\/890"}],"wp:attachment":[{"href":"http:\/\/115.29.108.60\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/115.29.108.60\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/115.29.108.60\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}