MCPcopy Index your code
hub / github.com/plotly/plotly.js / insertionSort

Function insertionSort

stackgl_modules/index.js:7098–7119  ·  view source on GitHub ↗
(d, axis, start, end, boxes, ids)

Source from the content-addressed store, hash-verified

7096
7097//Base case for median finding: Use insertion sort
7098function insertionSort(d, axis, start, end, boxes, ids) {
7099 var elemSize = 2 * d
7100 var boxPtr = elemSize * (start+1) + axis
7101 for(var i=start+1; i<end; ++i, boxPtr+=elemSize) {
7102 var x = boxes[boxPtr]
7103 for(var j=i, ptr=elemSize*(i-1);
7104 j>start && boxes[ptr+axis] > x;
7105 --j, ptr-=elemSize) {
7106 //Swap
7107 var aPtr = ptr
7108 var bPtr = ptr+elemSize
7109 for(var k=0; k<elemSize; ++k, ++aPtr, ++bPtr) {
7110 var y = boxes[aPtr]
7111 boxes[aPtr] = boxes[bPtr]
7112 boxes[bPtr] = y
7113 }
7114 var tmp = ids[j]
7115 ids[j] = ids[j-1]
7116 ids[j-1] = tmp
7117 }
7118 }
7119}
7120
7121//Find median using quick select algorithm
7122// takes O(n) time with high probability

Callers 4

findMedianFunction · 0.85
wrapperFunction · 0.85
quickSortFunction · 0.85
index.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…