MCPcopy
hub / github.com/kunal-kushwaha/DSA-Bootcamp-Java / remove

Method remove

lectures/24-heaps/code/heaps-1/Heap.java:44–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42 }
43
44 public T remove() throws Exception {
45 if (list.isEmpty()) {
46 throw new Exception("Removing from an empty heap!");
47 }
48
49 T temp = list.get(0);
50
51 T last = list.remove(list.size() - 1);
52 if (!list.isEmpty()) {
53 list.set(0, last);
54 downheap(0);
55 }
56
57 return temp;
58 }
59 private void downheap(int index) {
60 int min = index;
61 int left = left(index);

Callers 3

heapSortMethod · 0.95
helperMethod · 0.45
helperMethod · 0.45

Calls 5

downheapMethod · 0.95
isEmptyMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected