MCPcopy Index your code
hub / github.com/caseywebdev/react-list / pop

Function pop

docs/index.js:2140–2169  ·  view source on GitHub ↗
(heap)

Source from the content-addressed store, hash-verified

2138 return 0 === heap.length ? null : heap[0];
2139}
2140function pop(heap) {
2141 if (0 === heap.length) return null;
2142 var first = heap[0],
2143 last = heap.pop();
2144 if (last !== first) {
2145 heap[0] = last;
2146 a: for (
2147 var index = 0, length = heap.length, halfLength = length >>> 1;
2148 index < halfLength;
2149
2150 ) {
2151 var leftIndex = 2 * (index + 1) - 1,
2152 left = heap[leftIndex],
2153 rightIndex = leftIndex + 1,
2154 right = heap[rightIndex];
2155 if (0 > compare(left, last))
2156 rightIndex < length && 0 > compare(right, left)
2157 ? ((heap[index] = right),
2158 (heap[rightIndex] = last),
2159 (index = rightIndex))
2160 : ((heap[index] = left),
2161 (heap[leftIndex] = last),
2162 (index = leftIndex));
2163 else if (rightIndex < length && 0 > compare(right, last))
2164 (heap[index] = right), (heap[rightIndex] = last), (index = rightIndex);
2165 else break a;
2166 }
2167 }
2168 return first;
2169}
2170function compare(a, b) {
2171 var diff = a.sortIndex - b.sortIndex;
2172 return 0 !== diff ? diff : a.id - b.id;

Callers 11

advanceTimersFunction · 0.85
performWorkUntilDeadlineFunction · 0.85
pushHostContainerFunction · 0.85
popHostContainerFunction · 0.85
popHostContextFunction · 0.85
popHiddenContextFunction · 0.85
popSuspenseHandlerFunction · 0.85
popProviderFunction · 0.85
completeWorkFunction · 0.85
unwindWorkFunction · 0.85
unwindInterruptedWorkFunction · 0.85

Calls 1

compareFunction · 0.85

Tested by

no test coverage detected