MCPcopy Create free account
hub / github.com/plotly/plotly.js / isRangePermutation

Function isRangePermutation

src/traces/parcats/calc.js:490–509  ·  view source on GitHub ↗

* Determine whether an array contains a permutation of the integers from 0 to the array's length - 1 * @param {Array} inds * @return {boolean}

(inds)

Source from the content-addressed store, hash-verified

488 * @return {boolean}
489 */
490function isRangePermutation(inds) {
491 var indsSpecified = new Array(inds.length);
492
493 for(var i = 0; i < inds.length; i++) {
494 // Check for out of bounds
495 if(inds[i] < 0 || inds[i] >= inds.length) {
496 return false;
497 }
498
499 // Check for collisions with already specified index
500 if(indsSpecified[inds[i]] !== undefined) {
501 return false;
502 }
503
504 indsSpecified[inds[i]] = true;
505 }
506
507 // Nothing out of bounds and no collisions. We have a permutation
508 return true;
509}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…