Logic fail.

Also, why did cur work when it should have been cur.ID?
This commit is contained in:
Zixaphir 2014-01-05 10:25:47 -07:00
parent 6b3443c12a
commit 482f6444fe
3 changed files with 20 additions and 11 deletions

View File

@ -1500,11 +1500,12 @@
return;
}
cur = start === 0 ? this.first : this[start];
while (cur !== this[end]) {
if (!(next = cur.next, cur)) {
while (cur) {
next = cur.next;
this.rm(cur.ID);
if (!next || cur.ID === end) {
return;
}
this.rm(cur);
cur = next;
}
};
@ -1517,7 +1518,9 @@
}
delete this[ID];
this.length--;
return this.rmi(item);
this.rmi(item);
delete item.next;
return delete item.previous;
};
RandomAccessList.prototype.rmi = function(item) {

View File

@ -1506,11 +1506,12 @@
return;
}
cur = start === 0 ? this.first : this[start];
while (cur !== this[end]) {
if (!(next = cur.next, cur)) {
while (cur) {
next = cur.next;
this.rm(cur.ID);
if (!next || cur.ID === end) {
return;
}
this.rm(cur);
cur = next;
}
};
@ -1523,7 +1524,9 @@
}
delete this[ID];
this.length--;
return this.rmi(item);
this.rmi(item);
delete item.next;
return delete item.previous;
};
RandomAccessList.prototype.rmi = function(item) {

View File

@ -34,9 +34,10 @@ class RandomAccessList
splice: (start, end) ->
return unless @[end]
cur = if start is 0 then @first else @[start]
while cur isnt @[end]
return unless {next} = cur
@rm cur
while cur
{next} = cur
@rm cur.ID
return if not next or cur.ID is end
cur = next
rm: (ID) ->
@ -45,6 +46,8 @@ class RandomAccessList
delete @[ID]
@length--
@rmi item
delete item.next
delete item.previous
rmi: (item) ->
{prev, next} = item