View Javadoc

1   package cz.cuni.amis.utils.heap;
2   
3   import java.util.Collection;
4   import java.util.Comparator;
5   import java.util.Set;
6   
7   /**
8    * Interface for standard Heap (with addition of decreace/increase/changedKey operations).
9    * <p><p>
10   * We also assume that heap will use {@link Comparator} for comparing stored nodes.
11   * 
12   * @author Jimmy
13   *
14   * @param <NODE>
15   */
16  public interface IHeap<NODE> extends Collection<NODE> {
17  	
18  	/**
19  	 * Returns comparator that is used to compare the nodes in the heap.
20  	 * @return
21  	 */
22  	public Comparator<NODE> getComparator();
23  	
24  	/**
25  	 * Returns node with min-value from the heap.
26  	 * @return
27  	 */
28  	public NODE getMin();
29  	
30  	/**
31  	 * Deletes node with min-value, returns success (true if there was some object in the heap, false if there weren't).
32  	 * @return success
33  	 */
34  	public boolean deleteMin();
35  	
36  	/**
37  	 * "node" value has been decreased, bubble it through the heap.
38  	 * @param node
39  	 * @return
40  	 */
41  	public boolean decreaseKey(NODE node);
42  	
43  	/**
44  	 * "node" value has been increased, bubble it through the heap.
45  	 * @param node
46  	 * @return
47  	 */
48  	public boolean increaseKey(NODE node);
49  	
50  	/**
51  	 * "node" value has been changed (not sure if it was increased or decreased), bubble it through the heap.
52  	 * @param node
53  	 * @return
54  	 */
55  	public boolean changedKey(NODE node);
56  	
57  	/**
58  	 * Adds all items from 'items'.
59  	 * @param items
60  	 * @return
61  	 */
62  	public boolean addAll(NODE[] items);
63  	
64  	/**
65  	 * Whether this heap contains all 'items'.
66  	 * @param items
67  	 * @return
68  	 */
69  	public boolean containsAll(Object[] items);
70  	
71  	/**
72  	 * Whether this heap is empty.
73  	 * @return
74  	 */
75  	public boolean empty();
76  	
77  	/**
78  	 * Returns this heap as a set.
79  	 * @return
80  	 */
81  	public Set<NODE> toSet();	
82  
83  }