Comparing version 0.23.0-beta1 to 0.23.0
# Changelog | ||
## 0.23.0 (provisonal) | ||
## 0.23.0 | ||
* Adding `FixedReverseHeap`. | ||
* Adding `Heap.nsmallest` & `Heap.nlargest`. | ||
* Adding `MultiSet.isSubset` & `MultiSet.isSuperset`. | ||
* Adding `#.top` to `MultiSet`. | ||
@@ -8,0 +9,0 @@ * Adding missing `Heap` types. |
/** | ||
* Mnemonist MultiSet Kypings | ||
* Mnemonist MultiSet Typings | ||
* =========================== | ||
@@ -34,2 +34,4 @@ */ | ||
static from<I>(iterable: Iterable<I> | {[key: string]: I}): MultiSet<I>; | ||
static isSubset<T>(a: MultiSet<T>, b: MultiSet<T>): boolean; | ||
static isSuperset<T>(a: MultiSet<T>, b: MultiSet<T>): boolean; | ||
} |
@@ -280,5 +280,5 @@ /** | ||
this.items.forEach(function(multiplicty, value) { | ||
this.items.forEach(function(multiplicity, value) { | ||
for (i = 0; i < multiplicty; i++) | ||
for (i = 0; i < multiplicity; i++) | ||
callback.call(scope, value, value); | ||
@@ -308,3 +308,3 @@ }); | ||
value, | ||
multiplicty, | ||
multiplicity, | ||
i; | ||
@@ -321,7 +321,7 @@ | ||
value = step.value[0]; | ||
multiplicty = step.value[1]; | ||
multiplicity = step.value[1]; | ||
i = 0; | ||
} | ||
if (i >= multiplicty) { | ||
if (i >= multiplicity) { | ||
inContainer = false; | ||
@@ -383,4 +383,46 @@ return next(); | ||
/** | ||
* Function returning whether the multiset A is a subset of the multiset B. | ||
* | ||
* @param {MultiSet} A - First set. | ||
* @param {MultiSet} B - Second set. | ||
* @return {boolean} | ||
*/ | ||
MultiSet.isSubset = function(A, B) { | ||
var iterator = A.multiplicities(), | ||
step, | ||
key, | ||
mA; | ||
// Shortcuts | ||
if (A === B) | ||
return true; | ||
if (A.dimension > B.dimension) | ||
return false; | ||
while ((step = iterator.next(), !step.done)) { | ||
key = step.value[0]; | ||
mA = step.value[1]; | ||
if (B.multiplicity(key) < mA) | ||
return false; | ||
} | ||
return true; | ||
}; | ||
/** | ||
* Function returning whether the multiset A is a superset of the multiset B. | ||
* | ||
* @param {MultiSet} A - First set. | ||
* @param {MultiSet} B - Second set. | ||
* @return {boolean} | ||
*/ | ||
MultiSet.isSuperset = function(A, B) { | ||
return MultiSet.isSubset(B, A); | ||
}; | ||
/** | ||
* Exporting. | ||
*/ | ||
module.exports = MultiSet; |
{ | ||
"name": "mnemonist", | ||
"version": "0.23.0-beta1", | ||
"version": "0.23.0", | ||
"description": "Curated collection of data structures for the JavaScript language.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -13,3 +13,3 @@ /* eslint no-constant-condition: 0 */ | ||
*/ | ||
var DynamicArray = require('./dynamic-array.js'); | ||
var Vector = require('./vector.js'); | ||
@@ -33,6 +33,6 @@ // TODO: rename => ternary search tree | ||
// TODO: make it 16 bits | ||
this.characters = new DynamicArray.DynamicUint8Array(256); | ||
this.nextPointers = new DynamicArray.DynamicInt32Array(256); | ||
this.childPointers = new DynamicArray.DynamicUint32Array(256); | ||
this.maps = new DynamicArray.DynamicUint32Array(256); | ||
this.characters = new Vector.Uint8Vector(256); | ||
this.nextPointers = new Vector.Int32Vector(256); | ||
this.childPointers = new Vector.Uint32Vector(256); | ||
this.maps = new Vector.Uint32Vector(256); | ||
} | ||
@@ -39,0 +39,0 @@ |
@@ -22,2 +22,4 @@ /** | ||
// TODO: if sorting to get median, can split | ||
/** | ||
@@ -24,0 +26,0 @@ * Heap comparator used by the #.nearestNeighbors method. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
271172
9864