Skip to content

Instantly share code, notes, and snippets.

@huckfinnaafb
Created January 6, 2012 23:25
Show Gist options
  • Save huckfinnaafb/1572978 to your computer and use it in GitHub Desktop.
Save huckfinnaafb/1572978 to your computer and use it in GitHub Desktop.
function toIndice(vec, gw) {
return ((vec.y) * gw + vec.x);
}
function isUnique(array) {
var uniques = _.uniq(array);
return array.length === uniques.length;
};
var i, vectors = [], indices = [];
for (i = 0; i < 1000; i += 1) {
vectors.push(new Vector(0, 0, 0));
}
var j;
for (j = 0; j < vectors.length; j += 1) {
vectors[j].x = j;
indices.push(toIndice(vectors[j], 10));
}
var k;
for (k = 0; k < vectors.length; k += 1) {
vectors[k].y = k;
indices.push(toIndice(vectors[k], 10));
}
console.log(isUnique(indices));
=> false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment