UNPKG

@lazy-random/array-algorithm

Version:
48 lines (47 loc) 1.57 kB
!function(e, r) { "object" == typeof exports && "undefined" != typeof module ? r(exports, require("@lazy-random/array-rand-index")) : "function" == typeof define && define.amd ? define([ "exports", "@lazy-random/array-rand-index" ], r) : r((e = "undefined" != typeof globalThis ? globalThis : e || self).LazyRandomArrayAlgorithm = {}, e.arrayRandIndex); }(this, (function(e, r) { "use strict"; e.array_rebase = function array_rebase(e, r, n, t) { let a, o = 0, i = e.length; if ("number" == typeof n || "number" == typeof t) for (;i--; ) { let l = e[i] + r; if (!(l >= n && l <= t)) { a = !1; break; } a = !0, e[i] = l, o += l; } else { for (;i--; ) { let n = e[i] + r; e[i] = n, o += n; } a = !0; } return { bool: a, b_sum: o }; }, e.swapAlgorithm = function swapAlgorithm(e, n, t = r.arrayRandIndexByLength) { let a = e.length, o = n ? e : e.slice(); for (;a; ) { let e = t(a--); if (a === e) continue; let r = o[a]; o[a] = o[e], o[e] = r; } return o; }, e.swapAlgorithm2 = function swapAlgorithm2(e, n, t = r.arrayRandIndexByLength) { let a = e.length, o = n ? e : e.slice(), i = a, l = Math.ceil(i / 2); for (;a; ) { let e = t(i); if (a--, e === a && (e = t(a < l ? i : a)), a === e) continue; let r = o[a]; o[a] = o[e], o[e] = r; } return o; }, Object.defineProperty(e, "__esModule", { value: !0 }); })); //# sourceMappingURL=index.umd.production.min.cjs.map