Implementazione parziale Priority Queue
This commit is contained in:
18
exceptions/EmptyPriorityQueueException.java
Normal file
18
exceptions/EmptyPriorityQueueException.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package exceptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signals that the boundaries of a data structure have been illegally
|
||||||
|
* traversed (e.g. past the end of a list).
|
||||||
|
* @author Roberto Tamassia
|
||||||
|
*/
|
||||||
|
//Copyright (c) 2003 Brown University, Providence, RI
|
||||||
|
//Additional modifications and methods by xgiovio
|
||||||
|
|
||||||
|
public class EmptyPriorityQueueException extends RuntimeException {
|
||||||
|
public EmptyPriorityQueueException(String message) {
|
||||||
|
super (message);
|
||||||
|
}
|
||||||
|
public EmptyPriorityQueueException() {
|
||||||
|
super ("EmptyPriorityQueueException");
|
||||||
|
}
|
||||||
|
}
|
||||||
12
priorityqueue/Entry.java
Normal file
12
priorityqueue/Entry.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package priorityqueue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with xgiovio.macbookair.
|
||||||
|
* User: xgiovio
|
||||||
|
* Date: 01/04/14
|
||||||
|
* Time: 16:27
|
||||||
|
*/
|
||||||
|
public interface Entry<K,V> {
|
||||||
|
public K getKey();
|
||||||
|
public V getValue();
|
||||||
|
}
|
||||||
18
priorityqueue/PriorityQueue.java
Normal file
18
priorityqueue/PriorityQueue.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package priorityqueue;
|
||||||
|
|
||||||
|
import exceptions.EmptyPriorityQueueException;
|
||||||
|
import java.security.InvalidKeyException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created with xgiovio.macbookair.
|
||||||
|
* User: xgiovio
|
||||||
|
* Date: 01/04/14
|
||||||
|
* Time: 16:29
|
||||||
|
*/
|
||||||
|
public interface PriorityQueue<K,V> {
|
||||||
|
public int size();
|
||||||
|
public boolean isEmpty();
|
||||||
|
public Entry<K,V> min() throws EmptyPriorityQueueException;
|
||||||
|
public Entry<K,V> insert(K key, V value) throws InvalidKeyException;
|
||||||
|
public Entry<K,V> removeMin() throws EmptyPriorityQueueException;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user