-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPriorityQueue.java
More file actions
67 lines (60 loc) · 2.06 KB
/
PriorityQueue.java
File metadata and controls
67 lines (60 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//DHARITRI DIXIT: 300109815
/*
* Copyright 2014, Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
*
* Developed for use with the book:
*
* Data Structures and Algorithms in Java, Sixth Edition
* Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser
* John Wiley & Sons, 2014
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Interface for the priority queue ADT.
*
* @author Michael T. Goodrich
* @author Roberto Tamassia
* @author Michael H. Goldwasser
*/
public interface PriorityQueue<K extends Comparable,V> {
/**
* Returns the number of items in the priority queue.
* @return number of items
*/
int size();
/**
* Tests whether the priority queue is empty.
* @return true if the priority queue is empty, false otherwise
*/
boolean isEmpty();
/**
* Inserts a key-value pair and returns the entry created.
* @param key the key of the new entry
* @param value the associated value of the new entry
* @return the entry storing the new key-value pair
* @throws IllegalArgumentException if the key is unacceptable for this queue
*/
Entry<K,V> insert(K key, V value) throws IllegalArgumentException;
/**
* Returns (but does not remove) an entry with minimal key.
* @return entry having a minimal key (or null if empty)
*/
Entry<K,V> min();
/**
* Removes and returns an entry with minimal key.
* @return the removed entry (or null if empty)
*/
Entry<K,V> removeMin();
}