extra-array
Advanced tools
Comparing version 4.1.11 to 4.1.12
60
index.js
@@ -217,3 +217,3 @@ 'use strict'; | ||
var fs = fs || swapRaw$; | ||
return partialIntroSortRange$(x, 0, X, X, fc, fm, fs); | ||
return rangedPartialIntroSort$(x, 0, X, X, fc, fm, fs); | ||
} | ||
@@ -228,3 +228,3 @@ function rangedSort(x, i, I, fc = null, fm = null, fs = null) { | ||
var [i, I] = indexRange(x, i, I); | ||
return partialIntroSortRange$(x, i, I, I - i, fc, fm, fs); | ||
return rangedPartialIntroSort$(x, i, I, I - i, fc, fm, fs); | ||
} | ||
@@ -245,23 +245,23 @@ function partialSort(x, n, fc = null, fm = null, fs = null) { | ||
var [i, I] = indexRange(x, i, I); | ||
return partialIntroSortRange$(x, i, I, n, fc, fm, fs); | ||
return rangedPartialIntroSort$(x, i, I, n, fc, fm, fs); | ||
} | ||
function partialIntroSortRange$(x, i, I, n, fc, fm, fs) { | ||
function rangedPartialIntroSort$(x, i, I, n, fc, fm, fs) { | ||
var d = Math.floor(Math.log2(I - i) * 2); | ||
var s = 16; | ||
return partialIntroSortRangeDo$(x, i, I, d, s, n, fc, fm, fs); | ||
return rangedPartialIntroSortDo$(x, i, I, d, s, n, fc, fm, fs); | ||
} | ||
function partialIntroSortRangeDo$(x, i, I, d, s, n, fc, fm, fs) { | ||
function rangedPartialIntroSortDo$(x, i, I, d, s, n, fc, fm, fs) { | ||
if (n <= 0 || I - i <= 1) | ||
return x; | ||
if (I - i <= s) | ||
return partialInsertionSortRange$(x, i, I, n, fc, fm, fs); | ||
return rangedPartialInsertionSort$(x, i, I, n, fc, fm, fs); | ||
if (d <= 0) | ||
return partialHeapSortRange$(x, i, I, n, fc, fm, fs); | ||
return rangedPartialHeapSort$(x, i, I, n, fc, fm, fs); | ||
var p = i + Math.floor((I - i) * Math.random()); | ||
var p = quickSortPartitionRange$(x, i, I, p, fc, fm, fs); | ||
partialIntroSortRangeDo$(x, i, p, d, s, Math.min(p - i, n), fc, fm, fs); | ||
partialIntroSortRangeDo$(x, p + 1, I, d, s, Math.min(I - p - 1, n), fc, fm, fs); | ||
var p = rangedQuickSortPartition$(x, i, I, p, fc, fm, fs); | ||
rangedPartialIntroSortDo$(x, i, p, d, s, Math.min(p - i, n), fc, fm, fs); | ||
rangedPartialIntroSortDo$(x, p + 1, I, d, s, Math.min(I - p - 1, n), fc, fm, fs); | ||
return x; | ||
} | ||
function quickSortPartitionRange$(x, i, I, p, fc, fm, fs) { | ||
function rangedQuickSortPartition$(x, i, I, p, fc, fm, fs) { | ||
var wp = fm(x[p], p, x); | ||
@@ -279,15 +279,15 @@ var j = i - 1; | ||
} | ||
function partialHeapSortRange$(x, i, I, n, fc, fm, fs) { | ||
buildReverseMinHeapRange$(x, i, I, fc, fm, fs); | ||
function rangedPartialHeapSort$(x, i, I, n, fc, fm, fs) { | ||
rangedBuildReverseMinHeap$(x, i, I, fc, fm, fs); | ||
for (var r = I - 1; n > 0 && i < I; ++i, --n) { | ||
fs(x, i, r); | ||
reverseMinHeapifyRange$(x, i + 1, I, r, fc, fm, fs); | ||
rangedReverseMinHeapify$(x, i + 1, I, r, fc, fm, fs); | ||
} | ||
return x; | ||
} | ||
function buildReverseMinHeapRange$(x, i, I, fc, fm, fs) { | ||
function rangedBuildReverseMinHeap$(x, i, I, fc, fm, fs) { | ||
for (var r = I - Math.floor((I - i) / 2); r < I; ++r) | ||
reverseMinHeapifyRange$(x, i, I, r, fc, fm, fs); | ||
rangedReverseMinHeapify$(x, i, I, r, fc, fm, fs); | ||
} | ||
function reverseMinHeapifyRange$(x, i, I, r, fc, fm, fs) { | ||
function rangedReverseMinHeapify$(x, i, I, r, fc, fm, fs) { | ||
var s = r; | ||
@@ -302,10 +302,10 @@ var lt = 2 * r - I; | ||
fs(x, s, r); | ||
reverseMinHeapifyRange$(x, i, I, s, fc, fm, fs); | ||
rangedReverseMinHeapify$(x, i, I, s, fc, fm, fs); | ||
} | ||
} | ||
function buildMaxHeapRange$(x, i, I, fc, fm, fs) { | ||
function rangedBuildMaxHeap$(x, i, I, fc, fm, fs) { | ||
for (var r = i + Math.floor((I - i) / 2) - 1; r >= i; --r) | ||
maxHeapifyRange$(x, i, I, r, fc, fm, fs); | ||
rangedMaxHeapify$(x, i, I, r, fc, fm, fs); | ||
} | ||
function maxHeapifyRange$(x, i, I, r, fc, fm, fs) { | ||
function rangedMaxHeapify$(x, i, I, r, fc, fm, fs) { | ||
var s = r; | ||
@@ -320,12 +320,12 @@ var lt = 2 * r - i + 1; | ||
fs(x, s, r); | ||
maxHeapifyRange$(x, i, I, s, fc, fm, fs); | ||
rangedMaxHeapify$(x, i, I, s, fc, fm, fs); | ||
} | ||
} | ||
function partialInsertionSortRange$(x, i, I, n, fc, fm, fs) { | ||
function rangedPartialInsertionSort$(x, i, I, n, fc, fm, fs) { | ||
if (fs === swapRaw$) | ||
return partialInsertionSortRangeSwapless$(x, i, I, n, fc, fm); | ||
return rangedPartialInsertionSortSwapless$(x, i, I, n, fc, fm); | ||
else | ||
return partialInsertionSortRangeSwap$(x, i, I, n, fc, fm, fs); | ||
return rangedPartialInsertionSortSwap$(x, i, I, n, fc, fm, fs); | ||
} | ||
function partialInsertionSortRangeSwap$(x, i, I, n, fc, fm, fs) { | ||
function rangedPartialInsertionSortSwap$(x, i, I, n, fc, fm, fs) { | ||
for (var j = i + 1; j < I; ++j) { | ||
@@ -339,3 +339,3 @@ var key = x[j]; | ||
} | ||
function partialInsertionSortRangeSwapless$(x, i, I, n, fc, fm, fs) { | ||
function rangedPartialInsertionSortSwapless$(x, i, I, n, fc, fm, fs) { | ||
for (var j = i + 1; j < I; ++j) { | ||
@@ -448,3 +448,3 @@ var key = x[j]; | ||
var ih = fromRange(0, IH); | ||
buildMaxHeapRange$(ih, 0, IH, fc, i => fm(x[i], i, x), swapRaw$); | ||
rangedBuildMaxHeap$(ih, 0, IH, fc, i => fm(x[i], i, x), swapRaw$); | ||
var wr = fm(x[ih[0]], ih[0], x); | ||
@@ -456,3 +456,3 @@ for (var i = n; i < X; ++i) { | ||
ih[0] = i; | ||
maxHeapifyRange$(ih, 0, IH, 0, fc, i => fm(x[i], i, x), swapRaw$); | ||
rangedMaxHeapify$(ih, 0, IH, 0, fc, i => fm(x[i], i, x), swapRaw$); | ||
var wr = fm(x[ih[0]], ih[0], x); | ||
@@ -459,0 +459,0 @@ } |
{ | ||
"name": "extra-array", | ||
"version": "4.1.11", | ||
"version": "4.1.12", | ||
"description": "An array is a collection of values, stored contiguously.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
190617