queue
play

Queue D C B Queue with Stacks D B C A A B C D D A C B A - PDF document

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) {


  1. Discussion H Queue

  2. D C B Queue with Stacks D B C A A B C D D A C B

  3. A B C Stacks with Queues A B C D A D B C A B C D

  4. 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) {} }

  5. 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) { } }

  6. 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; } }

  7. 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() {} }

  8. Web Server Request Buffer (2) public void receive (Request r) { requests.offer(r); } public void reply() { Requests r = requests.get(); .... }

  9. 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

  10. 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