MCPcopy Create free account
hub / github.com/BaseXdb/basex / removeMin

Method removeMin

basex-core/src/main/java/org/basex/util/MinHeap.java:53–65  ·  view source on GitHub ↗

Removes the minimum from this heap. @return the removed entry's value

()

Source from the content-addressed store, hash-verified

51 * @return the removed entry's value
52 */
53 public V removeMin() {
54 final V val = minValue();
55 swap(0, --size);
56 int pos = 0;
57 while(pos < size / 2) {
58 int sm = 2 * pos + 1;
59 if(sm < size - 1 && compare(sm + 1, sm) < 0) sm++;
60 if(compare(pos, sm) <= 0) break;
61 swap(pos, sm);
62 pos = sm;
63 }
64 return val;
65 }
66
67 /**
68 * returns the value of the smallest key from this heap.

Callers 4

heapSortMethod · 0.95
heapPreSortMethod · 0.95
valueMethod · 0.95
valueMethod · 0.95

Calls 3

minValueMethod · 0.95
swapMethod · 0.95
compareMethod · 0.95

Tested by 2

heapSortMethod · 0.76
heapPreSortMethod · 0.76