Generics What is Generics?


Queues and Priority Queues



Download 1.18 Mb.
Page9/15
Date20.02.2022
Size1.18 Mb.
#58285
1   ...   5   6   7   8   9   10   11   12   ...   15
Generics-new

Queues and Priority Queues

A queue is a first-in/first-out data structure. Elements are appended to the end of the queue and are removed from the beginning of the queue. In a priority queue, elements are assigned priorities. When accessing elements, the element with the highest priority is removed first.

The Queue Interface

The PriorityQueue Class


Run

PriorityQueueDemo

The Map Interface

The Map interface maps keys to the elements. The keys are like indexes. In List, the indexes are integer. In Map, the keys can be any objects.

The Map Interface UML Diagram

Concrete Map Classes

Implementing Lists, Stacks and Queues

Lists

A list is a popular data structure to store data in sequential order. For example, a list of students, a list of available rooms, a list of cities, and a list of books, etc. can be stored using lists. The common operations on a list are usually the following:


Download 1.18 Mb.

Share with your friends:
1   ...   5   6   7   8   9   10   11   12   ...   15




The database is protected by copyright ©ininet.org 2024
send message

    Main page