Comparing version 1.13.1 to 1.14.1
// grab our gulp packages | ||
const gulp = require('gulp'); | ||
const gutil = require('gulp-util'); | ||
const eslint = require('gulp-eslint'); | ||
const fs = require('fs'); | ||
const stripJsonComments = require('strip-json-comments'); | ||
const { exec, spawn, spawnSync, execSync } = require('child_process'); | ||
const { execSync } = require('child_process'); | ||
@@ -9,0 +6,0 @@ function runCmd(taskName, cmd) { |
{ | ||
"name": "jstreemap", | ||
"version": "1.13.1", | ||
"description": "Library of associative containers.", | ||
"version": "1.14.1", | ||
"description": "Library of associative containers; it implements TreeMap, TreeSet, TreeMultiMap and TreeMultiSet classes", | ||
"main": "jstreemap.js", | ||
@@ -63,3 +63,2 @@ "scripts": { | ||
"gulp": "^3.9.1", | ||
"gulp-eslint": "^4.0.1", | ||
"gulp-util": "^3.0.8", | ||
@@ -66,0 +65,0 @@ "mocha": "^4.0.1", |
@@ -119,3 +119,3 @@ 'use strict'; | ||
if (newNode !== null) { | ||
if (!this.isLeaf(newNode)) { | ||
newNode.parent = oldNode.parent; | ||
@@ -462,29 +462,44 @@ } | ||
if (this.isBlack(node)) { | ||
node.color = this.fetchColor(child); | ||
this.eraseCase1(node); | ||
} | ||
this.replaceNode(node, child); | ||
if (this.head.size === 2) { | ||
// Root node must be BLACK | ||
child.color = BLACK; | ||
} | ||
// update head if necessary | ||
let h = this.head; | ||
if ((this.isLeaf(child)) | ||
&& (h.leftmost === node)) { | ||
let p = node.parent; | ||
if (p !== null) { | ||
h.leftmost = p; | ||
p.left = h; | ||
if (this.isLeaf(child)) { | ||
/* The node didn't have children and it was removed | ||
the head needs to update leftmost, rightmost pointers */ | ||
if (h.leftmost === node) { | ||
let p = node.parent; | ||
if (p !== null) { | ||
h.leftmost = p; | ||
p.left = h; | ||
} | ||
else { | ||
h.leftmost = h; | ||
} | ||
} | ||
else { | ||
h.leftmost = h; | ||
if (h.rightmost === node) { | ||
let p = node.parent; | ||
if (p !== null) { | ||
h.rightmost = p; | ||
p.right = h; | ||
} | ||
else { | ||
h.rightmost = h; | ||
} | ||
} | ||
} | ||
if ((this.isLeaf(child)) | ||
&& (h.rightmost === node)) { | ||
let p = node.parent; | ||
if (p !== null) { | ||
h.rightmost = p; | ||
p.right = h; | ||
else { | ||
// the node had a child. Now node is removed. Any references should point to the child now | ||
if (h.leftmost === node) { | ||
h.leftmost = child; | ||
child.left = h; | ||
} | ||
else { | ||
h.rightmost = h; | ||
if (h.rightmost === node) { | ||
h.rightmost = child; | ||
child.right = h; | ||
} | ||
@@ -491,0 +506,0 @@ } |
@@ -181,2 +181,24 @@ /*global should assert TreeSet*/ | ||
it('delete; rightmost and root', function(done) { | ||
let set = new TreeSet([1, 5, 3]); | ||
set.delete(5); | ||
set.delete(3); | ||
set.add(4); | ||
let expected = '{1,4}'; | ||
should.equal(expected, set.toString()); | ||
done(); | ||
}); | ||
it('delete; leftmost and root', function(done) { | ||
let set = new TreeSet([1, 5, 3]); | ||
set.delete(1); | ||
set.delete(3); | ||
set.add(2); | ||
let expected = '{2,5}'; | ||
should.equal(expected, set.toString()); | ||
done(); | ||
}); | ||
it('entries', function(done) { | ||
@@ -183,0 +205,0 @@ let set = new TreeSet([1, 2, 3]); |
@@ -658,2 +658,12 @@ /*global should assert Tree TreeNode KeyValuePolicy ReverseIterator BLACK RED compare*/ | ||
it('erase; delete leftmost and root', function(done) { | ||
let [t, n2, n1, n3] = buildTree(2, 1, 3); | ||
t.erase(n1); | ||
t.erase(n2); | ||
validateHead(t.head, n3, n3, n3, 1); | ||
validatePointers(n3, null, t.head, t.head, 3, BLACK); | ||
done(); | ||
}); | ||
it('erase; delete rightmost child', function(done) { | ||
@@ -681,2 +691,12 @@ let [t, n2, n1, n3] = buildTree(2, 1, 3); | ||
it('erase; delete rightmost and root', function(done) { | ||
let [t, n2, n1, n3] = buildTree(2, 1, 3); | ||
t.erase(n3); | ||
t.erase(n2); | ||
validateHead(t.head, n1, n1, n1, 1); | ||
validatePointers(n1, null, t.head, t.head, 1, BLACK); | ||
done(); | ||
}); | ||
it('erase; delete node with a single left child', function(done) { | ||
@@ -683,0 +703,0 @@ let [t, n20, n10, n30, n25, n35, n22] = buildTree(20, 10, 30, 25, 35, 22); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
12675500
12
246793
10