Geocities web hosting - Chapter 23 Data Structures and Collections 1165 26

Chapter 23 Data Structures and Collections 1165 26 // remove object from stack 27 public object Pop() 28 { 29 return stack.RemoveFromFront(); 30 } 31 32 // determine whether stack is empty 33 public bool IsEmpty() 34 { 35 return stack.IsEmpty(); 36 } 37 38 // output stack contents 39 public void Print() 40 { 41 stack.Print(); 42 } 43 44 } // end class StackComposition 45 } Fig. 23.12 Fig. 23.12Fig. 23FiFi.12g. 23.12g. 23.12StackCompositionclass encapsulates functionality of class List. (Part 2 of 2.) 23.5 Queues Another common data structure is the queue. A queue is similar to a checkout line in a supermarket the first person in line is served first; customers enter the line only at the end, and they wait to be served. Queue nodes are removed only from the head of the queue and are inserted only at the tail of the queue. For this reason, a queue is a first-in, first-out (FIFO) data structure. The insert and remove operations are known as enqueue and dequeue. Queues have many applications in computer systems. Most computers have only a single processor, so they can only serve one user at a time. Entries for the other users are placed in a queue. The entry at the front of the queue receives the first available service. Each entry gradually advances to the front of the queue as users receive service. Queues also support print spooling. A multiuser environment may have only one printer. Several users may send output to the printer. If the printer is busy, users may still generate other outputs, which are spooled to disk (much as thread is wound onto a spool), where they wait in a queue until the printer becomes available. Information packets also wait in queues in computer networks. Each time a packet arrives at a network node, the routing node must route it to the next node on the network along the path to the packet s final destination. The routing node routes one packet at a time, so additional packets are enqueued until the router can route them. A file server in a computer network handles file access requests from many clients throughout the network. Servers have a limited capacity to service requests from clients. When client requests exceed that capacity, the requests wait in queues. The program of Fig. 23.13 and Fig. 23.14 creates a queue class through inheritance from a list class. We want the QueueInheritanceclass (Fig. 23.13) to have methods Enqueue, Dequeue, IsEmptyand Print. Note that these methods are essentially the InsertAtBack, RemoveFromFront, IsEmptyand Printmethods of class List.
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision personal web hosting services

Leave a Reply