mafintosh / Unordered Array Remove
Licence: mit
Efficiently remove an element from an unordered array without doing a splice
Stars: ✭ 114
Programming Languages
javascript
184084 projects - #8 most used programming language
unordered-array-remove
Efficiently remove an element from an unordered array without doing a splice
npm install unordered-array-remove
Usage
var remove = require('unordered-array-remove')
var list = ['a', 'b', 'c', 'd', 'e']
remove(list, 2) // remove 'c'
console.log(list) // returns ['a', 'b', 'e', 'd'] (no 'c')
This works by popping the last element (which is fast because it doesn't need shift all array elements) and overwriting the removed index with this element.
License
MIT
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].