Discussion H Queue
D C B Queue with Stacks D B C A A B C D D A C B
A B C Stacks with Queues A B C D A D B C A B C D
Web Browser Cache (1) public class Browser { private Cache cache; public Browser (String homepage) { view(homepage); } public view (String pageurl) { Page p = cache.getCached(pageurl); if (p == null) { Page p = new Page(pageurl); cache.updateCache(pageurl); } view(p); } public void view(Page p) {} }
Web Browser Cache (2) public class Cache { private Queue<Page> cashed; private int limit; public Cache (int limit) { cached = new Queue<Page>(); this.limit = limit; } public boolean isCached (String url) { } public Page getCached (String url) { } public void updateCache(Page p) { } }
Web Browser Cache (3) public class Cache { private Queue<Page> current, other, qa, qb; private int limit; public Cache (int limit) { qa = new Queue<Page>(); qb = new Queue<Page>(); current = qa; other = qb; this.limit = limit; } }
Web Server Request Buffer (1) public class WebServer { private Queue<Request> requests; public Server () { requests = new Queue<Request>(); } public void receive (Request r) { } public void reply() {} public void run() {} }
Web Server Request Buffer (2) public void receive (Request r) { requests.offer(r); } public void reply() { Requests r = requests.get(); .... }
Remove from D End X A B C DeQue X A D B C At begining Insert A B C D A D B C
Virtual Memory Manager Pages: A B C D E F hit a b c f d f b c a full A D B B B B C C C C F D F D F F
Recommend
More recommend