MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / binaryInsertionSort

Function binaryInsertionSort

libs/echarts/echarts.simple.js:5863–5907  ·  view source on GitHub ↗
(array, lo, hi, start, compare)

Source from the content-addressed store, hash-verified

5861}
5862
5863function binaryInsertionSort(array, lo, hi, start, compare) {
5864 if (start === lo) {
5865 start++;
5866 }
5867
5868 for (; start < hi; start++) {
5869 var pivot = array[start];
5870
5871 var left = lo;
5872 var right = start;
5873 var mid;
5874
5875 while (left < right) {
5876 mid = left + right >>> 1;
5877
5878 if (compare(pivot, array[mid]) < 0) {
5879 right = mid;
5880 }
5881 else {
5882 left = mid + 1;
5883 }
5884 }
5885
5886 var n = start - left;
5887
5888 switch (n) {
5889 case 3:
5890 array[left + 3] = array[left + 2];
5891
5892 case 2:
5893 array[left + 2] = array[left + 1];
5894
5895 case 1:
5896 array[left + 1] = array[left];
5897 break;
5898 default:
5899 while (n > 0) {
5900 array[left + n] = array[left + n - 1];
5901 n--;
5902 }
5903 }
5904
5905 array[left] = pivot;
5906 }
5907}
5908
5909function gallopLeft(value, array, start, length, hint, compare) {
5910 var lastOffset = 0;

Callers 1

sortFunction · 0.70

Calls 1

compareFunction · 0.70

Tested by

no test coverage detected