sorted-indexof

WebJar for sorted-indexof

License

License

MIT
Categories

Categories

Dex General Purpose Libraries Utility
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

sorted-indexof
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

sorted-indexof
WebJar for sorted-indexof
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mafintosh/sorted-indexof

Download sorted-indexof

How to add to project

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

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.

sorted-indexof

Given two sorted arrays, a and b, efficiently return an array of indexes of b's elements in a.

Runs in O(n+m) where n and m are the sizes of the sorted arrays.

npm install sorted-indexof

Build Status

Usage

var indexOf = require('sorted-indexof')

var a = ['b', 'c', 'd', 'e', 'f']
var b = ['a', 'b', 'c', 'f', 'g', 'h']

console.log(indexOf(a, b))

Running the above returns

[ -1, 0, 1, 4, -1, -1 ]

Which corresponds to taking each element of b and running a.indexOf(el).

API

var indexes = indexOf(a, b)

Returns an array of indexes of bs elements in a. An an element in b does not exist in a, -1 is inserted.

Note that a and b MUST be sorted.

License

MIT

Versions

Version
1.0.0