Created
September 1, 2014 21:26
-
-
Save ailabs-software/a96a7272acf46c20e77f to your computer and use it in GitHub Desktop.
Removes 136,000 positions from an array of 278,000 in 50ms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function filterOutPositions(array, positions) // utility code, @param -- positions to remove | |
{ | |
var BE_DELETED = {}; | |
var arr = array.slice(0); // Clone the array so it can be re-used (non-destructive) | |
var pos_len = positions.length; | |
for (var i=0; i < pos_len; i++) | |
{ | |
arr[ positions[i] ] = BE_DELETED; | |
} | |
return arr.filter(function(arr_item) { return arr_item !== BE_DELETED; }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment