No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PriorityQueue.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package org.insa.algo.utils;
  2. /**
  3. * Interface representing a basic priority queue.
  4. *
  5. * @see https://en.wikipedia.org/wiki/Priority_queue
  6. */
  7. public interface PriorityQueue<E extends Comparable<E>> {
  8. /**
  9. * Check if the priority queue is empty.
  10. *
  11. * @return true if the queue is empty, false otherwise.
  12. */
  13. public boolean isEmpty();
  14. /**
  15. * @return Current size (number of elements) of this queue.
  16. */
  17. public int size();
  18. /**
  19. * Insert the given element into the queue.
  20. *
  21. * @param x Item to insert.
  22. */
  23. public void insert(E x);
  24. /**
  25. * Remove the given element from the priority queue.
  26. *
  27. * @param x Item to remove.
  28. */
  29. public void remove(E x) throws ElementNotFoundException;
  30. /**
  31. * Retrieve (but not remove) the smallest item in the queue.
  32. *
  33. * @return The smallest item in the queue.
  34. *
  35. * @throws EmptyPriorityQueueException if this queue is empty.
  36. */
  37. public E findMin() throws EmptyPriorityQueueException;
  38. /**
  39. * Remove and return the smallest item from the priority queue.
  40. *
  41. * @return The smallest item in the queue.
  42. *
  43. * @throws EmptyPriorityQueueException if this queue is empty.
  44. */
  45. public E deleteMin() throws EmptyPriorityQueueException;
  46. }