1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.collections;
  17. /**
  18. * Defines a collection for priority queues, which can insert, peek and pop.
  19. * <p>
  20. * This interface is now replaced by the <code>Buffer</code> interface.
  21. *
  22. * @deprecated Replaced by the Buffer interface and implementations in buffer subpackage.
  23. * Due to be removed in v4.0.
  24. * @since Commons Collections 1.0
  25. * @version $Revision: 1.14 $ $Date: 2004/02/18 01:15:42 $
  26. *
  27. * @author Peter Donald
  28. */
  29. public interface PriorityQueue {
  30. /**
  31. * Clear all elements from queue.
  32. */
  33. void clear();
  34. /**
  35. * Test if queue is empty.
  36. *
  37. * @return true if queue is empty else false.
  38. */
  39. boolean isEmpty();
  40. /**
  41. * Insert an element into queue.
  42. *
  43. * @param element the element to be inserted
  44. *
  45. * @throws ClassCastException if the specified <code>element</code>'s
  46. * type prevents it from being compared to other items in the queue to
  47. * determine its relative priority.
  48. */
  49. void insert(Object element);
  50. /**
  51. * Return element on top of heap but don't remove it.
  52. *
  53. * @return the element at top of heap
  54. * @throws java.util.NoSuchElementException if <code>isEmpty() == true</code>
  55. */
  56. Object peek();
  57. /**
  58. * Return element on top of heap and remove it.
  59. *
  60. * @return the element at top of heap
  61. * @throws java.util.NoSuchElementException if <code>isEmpty() == true</code>
  62. */
  63. Object pop();
  64. }