1 / 19

Advanced Java Programming

Advanced Java Programming. CSS446 Spring 2014 Nan Wang. Chapter Goals. Java Collection Framework Stack Queue & Priority Queue. Java Collections Framework. A hierarchy of interface types and classes for collecting objects. Each interface type is implemented by one or more classes. Stack.

jella
Télécharger la présentation

Advanced Java Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced Java Programming CSS446 Spring 2014 Nan Wang

  2. Chapter Goals • Java Collection Framework • Stack • Queue & Priority Queue

  3. Java Collections Framework • A hierarchy of interface types and classes for collecting objects. Each interface type is implemented by one or more classes.

  4. Stack • A stack remembers the order of its elements, but it does not allow you to insert elements in every position. • You can add and remove elements only at the top.

  5. Stacks • A stack is a collection of elements with last-in, first-out retrieval (LIFO). • Undo feature in word processor • Run-time stack that a processor or virtual machine keeps to store the values of variable in nested methods.

  6. Example-Balancing Perentheses

  7. Bus Stop Queue • In a queue, you add items to one end (the tail) and remove them from the other end (the head). • A priority queue is an unordered collection that has an efficient operation for removing the element with the highest priority. (reading assignments) front rear rear rear rear rear

  8. Queues • A Queue is a collection of elements with first-in first-out retrieval. • Print queue

  9. Priority Queues • A priority queue collects elements, each of which has a priority. • Elements are retrieved according to their priority. • New elements can be inserted in any order. • Removing an element from a priority queue, the element with the most urgent priority is retrieved.

  10. Priority Queue-Comparable Interface • Because the priority queue needs to be able to tell which element is the smallest, the added elements should belong to a class that implements the Comparable interface!!!

  11. Priority Queue

  12. Review • Java How to Program 9th • Chapter 7 ,8,9,10, 11,18,20 review questions • Big Java • Chapter 7-13,15 Review Questions

More Related