MCPcopy Create free account
hub / github.com/reactjs/react-rails / siftUp

Function siftUp

lib/assets/react-source/development/react.js:3067–3084  ·  view source on GitHub ↗
(heap, node, i)

Source from the content-addressed store, hash-verified

3065 }
3066
3067 function siftUp(heap, node, i) {
3068 var index = i;
3069
3070 while (true) {
3071 var parentIndex = index - 1 >>> 1;
3072 var parent = heap[parentIndex];
3073
3074 if (parent !== undefined && compare(parent, node) > 0) {
3075 // The parent is larger. Swap positions.
3076 heap[parentIndex] = node;
3077 heap[index] = parent;
3078 index = parentIndex;
3079 } else {
3080 // The parent is smaller. Exit.
3081 return;
3082 }
3083 }
3084 }
3085
3086 function siftDown(heap, node, i) {
3087 var index = i;

Callers 1

pushFunction · 0.85

Calls 1

compareFunction · 0.85

Tested by

no test coverage detected