100 likes | 206 Views
Discussion H. Queue. Queue with Stacks. A B C D. D C B. B C D. A. D C B A. Stacks with Queues. A B C D. D. A B C. A B C D. A B C. Web Browser Cache (1). public class Browser { private Cache cache; public Browser (String homepage) { view(homepage); }
E N D
Discussion H Queue
Queue with Stacks A B C D D C B B C D A D C B A
Stacks with Queues A B C D D A B C A B C D A B C
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(); .... }
DeQue A B C D D X A B C D X A B C A B C D Remove from End Insert At begining
Virtual Memory Manager Pages: A B C D E F hit a b c f d f b c a full B C D A B C F B C D B C F D F F