unordered-set

WebJar for unordered-set

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

unordered-set
Last Version

Last Version

2.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

unordered-set
WebJar for unordered-set
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mafintosh/unordered-set

Download unordered-set

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/unordered-set/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>unordered-set</artifactId>
    <version>2.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/unordered-set/
implementation 'org.webjars.npm:unordered-set:2.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/unordered-set/
implementation ("org.webjars.npm:unordered-set:2.0.1")
'org.webjars.npm:unordered-set:jar:2.0.1'
<dependency org="org.webjars.npm" name="unordered-set" rev="2.0.1">
  <artifact name="unordered-set" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='unordered-set', version='2.0.1')
)
libraryDependencies += "org.webjars.npm" % "unordered-set" % "2.0.1"
[org.webjars.npm/unordered-set "2.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

unordered-set

A couple of functions that make it easy to maintain an unordered set as an array in an efficient way

npm install unordered-set

build status

Usage

var set = require('unordered-set')
var list = []

var a = {hello: 'world'}
var b = {hej: 'verden'}

set.add(list, a)
set.add(list, b)

console.log(list) // prints a and b

set.remove(list, a)

console.log(list) // prints b

Items are removed and added using the same technique as in unordered-array-remove making the removal/additions run in O(1).

API

set.add(list, item)

Add an item. Notes that this sets the property ._index to a number. If you control the items you insert and this is performance critical it might be benefitial to set item._index = 0 in the item constructor as v8 tends to like that.

set.remove(list, item)

Remove an item from the set. Might change the order of the list as well.

bool = set.has(list, item)

Returns true if the item is in the list and false otherwise

set.swap(list, a, b)

Swap the positions of two elements in the set

License

MIT

Versions

Version
2.0.1