Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix typo in LLRedBlackTree remove() and add unit test.

  • Loading branch information...
commit 4e41cd218455f5e4302bc7d374e125c650966817 1 parent e873fcb
Michael Lehenbauer authored
Showing with 10 additions and 3 deletions.
  1. +2 −2 src/LLRedBlackTree.coffee
  2. +8 −1 test/LLRedBlackTree.js
View
4 src/LLRedBlackTree.coffee
@@ -150,7 +150,7 @@ mugs.LLRBNode = (() ->
return new mugs.None()
else
smallest = min(n.right).get()
- n = n.copy(smallest.key,smallest.val,_,_,removeMin(n.right))
+ n = n.copy(smallest.key,smallest.value,_,_,removeMin(n.right))
n = n.copy(_,_,_,_,remove(n.right, key))
return new mugs.Some(fixUp(n))
@@ -305,4 +305,4 @@ mugs.LLRBLeaf.prototype.count = () -> 0
mugs.LLRBLeaf.prototype.isEmpty = () -> true
mugs.LLRBLeaf.prototype.containsKey = (key) -> false
mugs.LLRBLeaf.prototype.values = () -> new mugs.List()
-mugs.LLRBLeaf.prototype.inorderTraversal = (f) -> return
+mugs.LLRBLeaf.prototype.inorderTraversal = (f) -> return
View
9 test/LLRedBlackTree.js
@@ -55,6 +55,13 @@ $(document).ready(function(){
var n3 = node.remove(1);
});
+ test("Removal values", function(){
+ var node = new LLRBNode(2,2).insert(1,1).insert(3,3);
+ var n2 = node.remove(2);
+ ok(n2.get(1).get() === 1);
+ ok(n2.get(3).get() === 3);
+ });
+
test("Test increasing", function(){
var total = 100;
@@ -261,4 +268,4 @@ $(document).ready(function(){
ok(map.size() === 0);
});
-});
+});
Please sign in to comment.
Something went wrong with that request. Please try again.