Skip to content

Commit 0351538

Browse files
committed
Site updated: 2018-11-10 23:33:58
1 parent a59d0f2 commit 0351538

File tree

10 files changed

+358
-7
lines changed

10 files changed

+358
-7
lines changed

2018/11/07/vueRouter/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ <h2 id="&#x5C0F;&#x7ED3;"><a href="#&#x5C0F;&#x7ED3;" class="headerlink" title="
127127
});
128128
document.body.appendChild(img);
129129
});
130-
</script></article><!-- lincense--><div class="license-wrapper"><p> <span>Author: </span><a href="https://bigbigdreamer.github.io">BillWang</a></p><p> <span>Link: </span><a href="https://bigbigdreamer.github.io/2018/11/07/vueRouter/">https://bigbigdreamer.github.io/2018/11/07/vueRouter/</a></p><p> <span>Copyright: </span><span>All articles in this blog are licensed under <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/3.0">CC BY-NC-SA 3.0</a> unless stating additionally.</span></p></div><div class="post-paginator"><a class="nextSlogan" href="/2018/11/06/Promise/" title="Promise探析"><span>NextPost ></span><br><span class="nextTitle">Promise探析</span></a><div class="clear"></div></div><div id="comment"><div id="lv-container" data-id="city" data-uid="MTAyMC80MDczNC8xNzI2MA"><script>(function (d, s) {
130+
</script></article><!-- lincense--><div class="license-wrapper"><p> <span>Author: </span><a href="https://bigbigdreamer.github.io">BillWang</a></p><p> <span>Link: </span><a href="https://bigbigdreamer.github.io/2018/11/07/vueRouter/">https://bigbigdreamer.github.io/2018/11/07/vueRouter/</a></p><p> <span>Copyright: </span><span>All articles in this blog are licensed under <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/3.0">CC BY-NC-SA 3.0</a> unless stating additionally.</span></p></div><div class="post-paginator"><a class="prevSlogan" href="/2018/11/10/queue模拟/" title="queue模拟"><span>< PreviousPost</span><br><span class="prevTitle">queue模拟</span></a><a class="nextSlogan" href="/2018/11/06/Promise/" title="Promise探析"><span>NextPost ></span><br><span class="nextTitle">Promise探析</span></a><div class="clear"></div></div><div id="comment"><div id="lv-container" data-id="city" data-uid="MTAyMC80MDczNC8xNzI2MA"><script>(function (d, s) {
131131
var j, e = d.getElementsByTagName(s)[0];
132132
if (typeof LivereTower === 'function') { return; }
133133
j = d.createElement(s);

2018/11/10/queue模拟/index.html

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<!DOCTYPE html><html><head><meta name="generator" content="Hexo 3.8.0"><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"><meta name="author" content="BillWang"><meta name="renderer" content="webkit"><meta name="copyright" content="BillWang"><meta name="keywords" content="BillWang"><meta name="description" content="null"><meta name="Cache-Control" content="no-cache"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>queue模拟 · BillWang's Blog</title><link rel="stylesheet" href="/css/style.css?v=2018.7.9"><link rel="stylesheet" href="/css/animation.css?v=2018.7.9"><link rel="icon" href="/img/assets/alarm.ico"><link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css?version=1.5.6"><!-- scripts--><script>(function( w ){
2+
"use strict";
3+
// rel=preload support test
4+
if( !w.loadCSS ){
5+
w.loadCSS = function(){};
6+
}
7+
// define on the loadCSS obj
8+
var rp = loadCSS.relpreload = {};
9+
// rel=preload feature support test
10+
// runs once and returns a function for compat purposes
11+
rp.support = (function(){
12+
var ret;
13+
try {
14+
ret = w.document.createElement( "link" ).relList.supports( "preload" );
15+
} catch (e) {
16+
ret = false;
17+
}
18+
return function(){
19+
return ret;
20+
};
21+
})();
22+
23+
// if preload isn't supported, get an asynchronous load by using a non-matching media attribute
24+
// then change that media back to its intended value on load
25+
rp.bindMediaToggle = function( link ){
26+
// remember existing media attr for ultimate state, or default to 'all'
27+
var finalMedia = link.media || "all";
28+
29+
function enableStylesheet(){
30+
link.media = finalMedia;
31+
}
32+
33+
// bind load handlers to enable media
34+
if( link.addEventListener ){
35+
link.addEventListener( "load", enableStylesheet );
36+
} else if( link.attachEvent ){
37+
link.attachEvent( "onload", enableStylesheet );
38+
}
39+
40+
// Set rel and non-applicable media type to start an async request
41+
// note: timeout allows this to happen async to let rendering continue in IE
42+
setTimeout(function(){
43+
link.rel = "stylesheet";
44+
link.media = "only x";
45+
});
46+
// also enable media after 3 seconds,
47+
// which will catch very old browsers (android 2.x, old firefox) that don't support onload on link
48+
setTimeout( enableStylesheet, 3000 );
49+
};
50+
51+
// loop through link elements in DOM
52+
rp.poly = function(){
53+
// double check this to prevent external calls from running
54+
if( rp.support() ){
55+
return;
56+
}
57+
var links = w.document.getElementsByTagName( "link" );
58+
for( var i = 0; i < links.length; i++ ){
59+
var link = links[ i ];
60+
// qualify links to those with rel=preload and as=style attrs
61+
if( link.rel === "preload" && link.getAttribute( "as" ) === "style" && !link.getAttribute( "data-loadcss" ) ){
62+
// prevent rerunning on link
63+
link.setAttribute( "data-loadcss", true );
64+
// bind listeners to toggle media back
65+
rp.bindMediaToggle( link );
66+
}
67+
}
68+
};
69+
70+
// if unsupported, run the polyfill
71+
if( !rp.support() ){
72+
// run once at least
73+
rp.poly();
74+
75+
// rerun poly on an interval until onload
76+
var run = w.setInterval( rp.poly, 500 );
77+
if( w.addEventListener ){
78+
w.addEventListener( "load", function(){
79+
rp.poly();
80+
w.clearInterval( run );
81+
} );
82+
} else if( w.attachEvent ){
83+
w.attachEvent( "onload", function(){
84+
rp.poly();
85+
w.clearInterval( run );
86+
} );
87+
}
88+
}
89+
90+
91+
// commonjs
92+
if( typeof exports !== "undefined" ){
93+
exports.loadCSS = loadCSS;
94+
}
95+
else {
96+
w.loadCSS = loadCSS;
97+
}
98+
}( typeof global !== "undefined" ? global : this ) );</script><script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js" defer></script><script src="/js/main.js?v=2018.7.9" defer></script><!-- fancybox--><link rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.css" as="style" onload="this.onload=null;this.rel='stylesheet'"><script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.js" defer></script><!-- busuanzi--><script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script></head><body><section class="profile-close" id="cxo-profile"><div class="profile-avatar"><i class="fa fa-caret-left"></i><img src="/img/assets/alarm.jpg"></div><!--.profile-saying
99+
i.fa.fa-comment
100+
.saying--><div class="cxo-profile-inner"><div class="profile-name">BillWang</div><div class="profile-signature">每个人距离成功都只差一步坚持。</div><div class="friends"><div>FRIENDS</div><span><a href="https://desirefire.github.io/" target="_black">Natalia Tsunako</a></span><span><a href="//itzmn.github.io" target="_black">七夜</a></span><span><a href="http://elickzhao.github.io" target="_black">elickzhao</a></span></div><div class="read-progress"></div></div></section><header id="cxo-intro" style="height: 70vh;background-image: url(/img/intro/index-lg.png);"><nav id="cxo-intro-nav"><section><div class="intro-nav-title"><a href="/">凌瑶宫</a></div><div class="intro-nav-label-box"><a href="/">Home</a><a href="/about/">About</a><a href="/archives/">Archives</a><a href="/tags/">Tags</a></div><i class="fa fa-bars intro-nav-menu"><div class="intro-nav-drop"><a href="/">Home</a><a href="/about/">About</a><a href="/archives/">Archives</a><a href="/tags/">Tags</a></div></i><div class="clear"></div></section></nav><h1 class="post-title">queue模拟</h1><div class="post-intros"><div class="post-intro-meta"><span class="post-intro-time"><i class="post-intro-calendar fa fa-edit"></i><span>2018-11-10</span></span><span class="post-intro-tags"><a class="intro-tag fa fa-tag" href="javascript:void(0)" date-tags="queue"> queue</a><a class="intro-tag fa fa-tag" href="javascript:void(0)" date-tags="es6"> es6</a><a class="intro-tag fa fa-tag" href="javascript:void(0)" date-tags="数据结构"> 数据结构</a></span></div><div class="post-intro-read"><span> Word count: <span class="post-count">262</span> | Reading time: <span class="post-count">1</span>min</span></div></div></header><article class="cxo-up" id="cxo-content-outer"><section id="cxo-content-inner"><article class="article-entry" id="post"><h3 id="&#x524D;&#x8A00;"><a href="#&#x524D;&#x8A00;" class="headerlink" title="&#x524D;&#x8A00;"></a>&#x524D;&#x8A00;</h3><blockquote>
101+
<p>&#x2003;&#x2003;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x662F;&#x6BCF;&#x4E00;&#x4E2A;&#x7A0B;&#x5E8F;&#x5458;&#x7684;&#x5185;&#x529F;&#xFF0C;&#x65E0;&#x8BBA;&#x600E;&#x6837;&#xFF0C;&#x6211;&#x4EEC;&#x90FD;&#x5E94;&#x8BE5;&#x53BB;&#x575A;&#x6301;&#x4FEE;&#x70BC;&#x597D;&#x8FD9;&#x95E8;&#x5185;&#x529F;&#x5FC3;&#x6CD5;&#x3002;&#x5E9F;&#x8BDD;&#x4E0D;&#x591A;&#x8BB2;&#xFF0C;&#x5F00;&#x59CB;queue&#x6A21;&#x62DF;&#xFF0C;&#x4ECA;&#x5929;&#x5F00;&#x59CB;&#xFF0C;&#x6BCF;&#x5929;&#x6A21;&#x62DF;&#x4E00;&#x79CD;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x3002;</p>
102+
</blockquote>
103+
<h3 id="Demo"><a href="#Demo" class="headerlink" title="Demo"></a>Demo</h3><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * @time 2018/11/10 22:54</span><br><span class="line"> * @author Bill Wang &lt;1826001146@qq.com&gt;</span><br><span class="line"> * @desc &#x961F;&#x5217;&#x6A21;&#x62DF;</span><br><span class="line"> * @param null {string}</span><br><span class="line"> * @todo &#x6A21;&#x62DF;&#x961F;&#x5217;</span><br><span class="line"> */</span><br><span class="line">class Queue {</span><br><span class="line"> <span class="function"><span class="title">constructor</span></span>() {</span><br><span class="line"> this.queue = [];</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> enter(element) {</span><br><span class="line"> this.queue.push(element);</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="title">outer</span></span>() {</span><br><span class="line"> this.queue.shift();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="title">empty</span></span>() {</span><br><span class="line"> this.queue = [];</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="function"><span class="title">show</span></span>() {</span><br><span class="line"> <span class="built_in">return</span> this.queue;</span><br><span class="line"> }</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">const queue = new Queue();</span><br><span class="line">queue.enter(3);</span><br><span class="line">queue.enter(4);</span><br><span class="line">queue.enter(5);</span><br><span class="line">queue.enter(6);</span><br><span class="line">console.log(queue.show());</span><br><span class="line">queue.outer();</span><br><span class="line">console.log(queue.show());</span><br><span class="line">queue.empty();</span><br><span class="line">console.log(queue.show());</span><br></pre></td></tr></tbody></table></figure>
104+
<h3 id="&#x539F;&#x7406;&#x89E3;&#x6790;"><a href="#&#x539F;&#x7406;&#x89E3;&#x6790;" class="headerlink" title="&#x539F;&#x7406;&#x89E3;&#x6790;"></a>&#x539F;&#x7406;&#x89E3;&#x6790;</h3><blockquote>
105+
<p>&#x2003;&#x2003;&#x4F17;&#x6240;&#x5468;&#x77E5;&#xFF0C;&#x961F;&#x5217;&#x7684;&#x89C4;&#x5219;&#x5C31;&#x662F;&#x5148;&#x8FDB;&#x5148;&#x51FA;&#xFF0C;&#x6240;&#x4EE5;&#x65E0;&#x8BBA;&#x662F;<code>enter</code>&#x8FD8;&#x662F;<code>outer</code>&#xFF0C;<code>empty</code>&#x6216;&#x8005;<code>show</code>&#xFF0C;&#x90FD;&#x9075;&#x5FAA;&#x961F;&#x5217;&#x7684;&#x4E00;&#x822C;&#x539F;&#x5219;&#xFF0C;&#x8FD9;&#x91CC;&#x6211;&#x7528;&#x6570;&#x7EC4;&#x6A21;&#x62DF;&#x3002;</p>
106+
</blockquote>
107+
<script>
108+
document.querySelectorAll('.github-emoji')
109+
.forEach(el => {
110+
if (!el.dataset.src) { return; }
111+
const img = document.createElement('img');
112+
img.style = 'display:none !important;';
113+
img.src = el.dataset.src;
114+
img.addEventListener('error', () => {
115+
img.remove();
116+
el.style.color = 'inherit';
117+
el.style.backgroundImage = 'none';
118+
el.style.background = 'none';
119+
});
120+
img.addEventListener('load', () => {
121+
img.remove();
122+
});
123+
document.body.appendChild(img);
124+
});
125+
</script></article><!-- lincense--><div class="license-wrapper"><p> <span>Author: </span><a href="https://bigbigdreamer.github.io">BillWang</a></p><p> <span>Link: </span><a href="https://bigbigdreamer.github.io/2018/11/10/queue模拟/">https://bigbigdreamer.github.io/2018/11/10/queue模拟/</a></p><p> <span>Copyright: </span><span>All articles in this blog are licensed under <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/3.0">CC BY-NC-SA 3.0</a> unless stating additionally.</span></p></div><div class="post-paginator"><a class="nextSlogan" href="/2018/11/07/vueRouter/" title="vue-router"><span>NextPost ></span><br><span class="nextTitle">vue-router</span></a><div class="clear"></div></div><div id="comment"><div id="lv-container" data-id="city" data-uid="MTAyMC80MDczNC8xNzI2MA"><script>(function (d, s) {
126+
var j, e = d.getElementsByTagName(s)[0];
127+
if (typeof LivereTower === 'function') { return; }
128+
j = d.createElement(s);
129+
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
130+
j.async = true;
131+
e.parentNode.insertBefore(j, e);
132+
})(document, 'script');</script></div></div></section></article><footer id="cxo-footer-outer"><div id="cxo-footer-inner"><p class="footer-container"><span>Site by </span><a href="http://hexo.io"><span>Hexo</span></a><span> | theme </span><a href="https://github.com/Longlongyu/hexo-theme-Cxo"><span>Cxo</span></a></p><i class="fa fa-user"> </i><span id="busuanzi_value_site_uv"></span><span> | </span><i class="fa fa-eye"> </i><span id="busuanzi_value_site_pv"></span><script>var _hmt = _hmt || [];
133+
(function() {
134+
var hm = document.createElement("script");
135+
hm.src = "https://hm.baidu.com/hm.js?" + '490c72c80e7c5f485272ffc6d84c956b';
136+
var s = document.getElementsByTagName("script")[0];
137+
s.parentNode.insertBefore(hm, s);
138+
})();</script></div></footer><!-- catelog--><div class="toc-wrapper" style="top: 70vh;"><div class="toc-catalog"><i class="fa fa-list"> </i><span>CATALOG</span></div><ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#前言"><span class="toc-number">1.</span> <span class="toc-text">前言</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Demo"><span class="toc-number">2.</span> <span class="toc-text">Demo</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#原理解析"><span class="toc-number">3.</span> <span class="toc-text">原理解析</span></a></li></ol></div><!-- top--><i class="fa fa-arrow-up close" id="go-up" aria-hidden="true"></i></body></html>

0 commit comments

Comments
 (0)