1. unordered-array-remove
Efficiently remove an element from an unordered array without doing a splice
unordered-array-remove
Package: unordered-array-remove
Created by: mafintosh
Last modified: Tue, 28 Jun 2022 05:12:47 GMT
Version: 1.0.2
License: MIT
Downloads: 27,677
Repository: https://github.com/mafintosh/unordered-array-remove

Install

npm install unordered-array-remove
yarn add unordered-array-remove

unordered-array-remove

Efficiently remove an element from an unordered array without doing a splice

npm install unordered-array-remove

build status

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

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code