Skip to content

Commit

Permalink
Adjusted clear() to set _head to null as opposed to _head.next and _h…
Browse files Browse the repository at this point in the history
…ead.data to null (caused issue with adding items to a cleared list).
  • Loading branch information
BrianMilton committed Jul 23, 2013
1 parent 86fefb6 commit 482181d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
14 changes: 7 additions & 7 deletions AMDLinkedList.js
Expand Up @@ -2,7 +2,7 @@
* LinkedList for JavaScript.
* Eventually this will completely emulate a regular Java linked list.
* Copyright 2013, Brian Milton
* Version: 0.38.2 (22nd July 2013)
* Version: 0.38.3 (22nd July 2013)
*/
define("LinkedList", function() {

Expand Down Expand Up @@ -116,13 +116,12 @@ define("LinkedList", function() {
if(this._length === 0) {
return;
}
var head = this._head;
var tail = this._tail;
head.data = null;
head.next = null;
tail.data = null;
var node = {data:null,next:null}
this._head = null;
this._tail = null;
this._length = 0;
MODCOUNT++;
return;
};

/*
Expand Down Expand Up @@ -501,7 +500,8 @@ define("LinkedList", function() {
if(current.next !== null) {
var nextNode = current.next;
// If not, apply the function passed on this and the next node.
if(sortFunction(current.data,nextNode.data)) {
var sortResult = sortFunction(current.data,nextNode.data);
if(sortResult === true || sortResult > 0) {
// Result of the function is true...
// Sort isn't complete (nextNode is not null)
sortDone = false;
Expand Down
14 changes: 7 additions & 7 deletions LinkedList.js
Expand Up @@ -2,7 +2,7 @@
* LinkedList for JavaScript.
* Eventually this will completely emulate a regular Java linked list.
* Copyright 2013, Brian Milton
* Version: 0.38.2 (22nd July 2013)
* Version: 0.38.3 (22nd July 2013)
*/
(function() {

Expand Down Expand Up @@ -116,13 +116,12 @@
if(this._length === 0) {
return;
}
var head = this._head;
var tail = this._tail;
head.data = null;
head.next = null;
tail.data = null;
var node = {data:null,next:null}
this._head = null;
this._tail = null;
this._length = 0;
MODCOUNT++;
return;
};

/*
Expand Down Expand Up @@ -501,7 +500,8 @@
if(current.next !== null) {
var nextNode = current.next;
// If not, apply the function passed on this and the next node.
if(sortFunction(current.data,nextNode.data)) {
var sortResult = sortFunction(current.data,nextNode.data);
if(sortResult === true || sortResult > 0) {
// Result of the function is true...
// Sort isn't complete (nextNode is not null)
sortDone = false;
Expand Down
2 changes: 2 additions & 0 deletions LinkedList.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 482181d

Please sign in to comment.