Nodejs Utililty Methods Array Exchange

List of utility methods to do Array Exchange

Description

The list of methods to do Array Exchange are organized into topic(s).

Method

exchange(i1,i2)
Array.prototype.exchange = function(i1,i2) {
  var tmp = this[i1];
  this[i1] = this[i2];
  this[i2] = tmp;
};
var randomizeInPlace = function(A) {
  for (var i = 1, n = A.length; i < n; i++){
    A.exchange(i,getRandomIntInclusive(0,i));
  return A;
};
module.exports = randomizeInPlace;
exchange(i1,i2)
Array.prototype.exchange = function(i1,i2) {
  var tmp = this[i1];
  this[i1] = this[i2];
  this[i2] = tmp;
};