### Question:
KHeap { public boolean pop() { if (size() == 0) { return false; } if (size() == 1) { size--; return true; } if (additionalData != null) { int additionalSize = additionalData.size(); if (additionalSize == 2) { additionalData = null; return true; } additionalData.remove(additionalSize-1); additionalData.remove(additionalSize-2); return true; } size--; data[0] = data[2*size]; data[1] = data[2*size+1]; additionalData = null; siftDown(0); return true; } KHeap(int maxSize);  KHeap(int maxSize, boolean extensible); boolean offer(final int id, final double weight); int size(); void dump(); long getId(final int i); double getWeight(final int i); int getExtensionSize(); boolean pop(); int popLE(double threshold);  }### Answer:
@Test public void testPop() { KHeap heap = new KHeap(3, true); for ( int i = 0; i < 5; i++ ){ heap.offer(i, i); } assertEquals(3, heap.size()); assertEquals(2, heap.getId(0)); assertEquals(2d, heap.getWeight(0), 0d); boolean popped = heap.pop(); assertTrue(popped); assertEquals(2, heap.size()); assertEquals(3, heap.getId(0)); assertEquals(3d, heap.getWeight(0), 0d); assertEquals(4d, heap.getWeight(1), 0d); assertEquals(4, heap.getId(1)); popped = heap.pop(); assertTrue(popped); assertEquals(1, heap.size()); assertEquals(4d, heap.getWeight(0), 0d); assertEquals(4, heap.getId(0)); popped = heap.pop(); assertTrue(popped); assertEquals(0, heap.size()); popped = heap.pop(); assertFalse(popped); assertEquals(0, heap.size()); heap.offer(1, 1); heap.offer(2, 2); heap.offer(3, 1); heap.offer(4, 1); heap.offer(5, 1); assertEquals(5, heap.size()); assertEquals(2, heap.getExtensionSize()); popped = heap.pop(); assertTrue(popped); assertEquals(4, heap.size()); assertEquals(1, heap.getExtensionSize()); popped = heap.pop(); assertTrue(popped); assertEquals(3, heap.size()); assertEquals(0, heap.getExtensionSize()); popped = heap.pop(); assertTrue(popped); assertEquals(2, heap.size()); popped = heap.pop(); assertTrue(popped); assertEquals(1, heap.size()); assertEquals(2d, heap.getWeight(0), 0d); }