node-linkedlist
Advanced tools
| var should = require('should') | ||
| , LinkedList = require('../src/LinkedList') | ||
| , stdListItems = [ | ||
| {id: 4, username: "agadfg", password: "Test 1", field3: 1234, field4: 10.45}, | ||
| {id: 1, username: "ardze5zeh", password: "Test 2", field3: 2345, field4: false}, | ||
| {id: 7, username: "Name ohne Ende", password: "Test 3", field3: 3456, field4: true}, | ||
| {id: 23, username: "w5zsdghxfdgh", password: "Test 4", field3: 4567, field4: 342345345345345} | ||
| ]; | ||
| describe('Test set array with items to empty list', function() { | ||
| it('Test to set items array.', function(done) { | ||
| // Create list with custom nodes. | ||
| var list = LinkedList.Create(); | ||
| // Assign values to the custom node and push to the list. | ||
| list.setItems(stdListItems, function callback(err, newList) { | ||
| // Check if there is an error and size of the linked list. | ||
| should(err).be.null(); | ||
| should(newList.size).be.equal(4); | ||
| // Jump directly to the end of the list and check validity of the node. | ||
| var nodes = newList.toArray(); | ||
| should(nodes).be.lengthOf(4); | ||
| var node = nodes[0]; | ||
| should(node).be.not.null(); | ||
| should(node.id).be.equal(4); | ||
| node = nodes[nodes.length -1]; | ||
| should(node).be.not.null(); | ||
| should(node.id).be.equal(23); | ||
| done(); | ||
| }); | ||
| }); | ||
| }); |
+9
-16
| { | ||
| "name": "node-linkedlist", | ||
| "version": "0.1.3", | ||
| "version": "0.1.4", | ||
| "description": "Double linked list features", | ||
@@ -16,16 +16,3 @@ "main": "index.js", | ||
| }, | ||
| "scripts": { | ||
| "test": [ | ||
| "TestAddSingleNodeObjectToList.js", | ||
| "TestCleanUpList.js", | ||
| "TestCustomNodeBackwardTraversing.js", | ||
| "TestCustomNodeSearchByProperty.js", | ||
| "TestCustomNodeTraversing.js", | ||
| "TestIterateOverList.js", | ||
| "TestNodeDeletion.js", | ||
| "TestStdNodeSearchByProperty.js", | ||
| "TestStdNodeTraversing.js", | ||
| "TestToArrayFunction.js" | ||
| ] | ||
| }, | ||
| "scripts": {}, | ||
| "keywords": [ | ||
@@ -42,3 +29,9 @@ "unary tree", | ||
| }, | ||
| "license": "LGPL-3.0" | ||
| "license": "LGPL-3.0", | ||
| "readme": "<h1>LinkedList</h1>\n\nAn implementation of the concept of double linked lists.\n\n<h2>Documentation</h2>\n\n<h3>How to use</h3>\n\nQuick example to get an instance of the linked list:\n```javascript\n var LinkedList = require('node-linkedlist')\n , User = require('../Object/User')\n , list = LinkedList.Create(User);\n \n ... \n var user = User.Create();\n list.add(user, function(err, listObj) {\n ... \n ... \n });\n```\n\n<h3>Linked list</h3>\n\n<a name=\"size\">\n<h4>size</h4>\n\nThe number of nodes linked to each other in a row.\n\n<strong>Example</strong>\n\n```javascript\nvar list = require(\"node-linkedlist\").Create()\n...\n console.log(list.size);\n```\n\n<a name=\"setDataType\">\n<h4>setDataType(dataType)</h4>\n\nYou are not fixed to use ''LinkedList'' as it is with the internal standard node. You can use it to chain\nyour own business objects too. The only thing you have to do is to extend the standard node object and publish\nthe constructor of you class to the ''LinkedList'' instance.\nTo publish your own node class without inherit from the standard node you only have to implement the methods that are described at the\nbottom of the documentation under <a href=\"#node\">List node</a>\n<br/>\n<br/>\n<strong>Arguments</strong>\n\n* `dataType` (constructor) - The constructor of the class extending the standard node object.\n* `return` (LinkedList) - The list itself is returned.\n\n<strong>Example</strong>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create()\n , User = require('<path>/User');\n\n list.setDataType(User);\n```\n\nAlternatively you can publish the constructor directly on create the ''LinkedList'' instance.\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , User = require('<path>/User')\n , list = LinkedList.Create(User);\n\n ...\n ...\n```\nIt is important to know that if you publish a constructor to the ''LinkedList'' instance after adding nodes all of them are lost because\npublishing requires to set a new first node of the published constructor. It is planned to realize a mixed-mode of nodes which have\nimplemented a standard interface.\n\n<a name=\"add\">\n<h4>add(data[, callback])</h4>\n\nAdd a new node to the end of the list.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* `data` (string) - The data to add to the list. It can be a node object too.\n* `callback` (function) - The callback function with parameter `err` and `listObj`.\n* `return` (listObj) - The `LinkedList` instance itself.\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create()\n , node = list.node;\n\n ...\n list.add('FirstName', function(err, listObj) {\n if (err) console.log(err);\n else {\n console.log(listObj.size);\n }\n });\n```\n\n<a name=\"searchBy\">\n<h4>searchBy(property, value)</h4>\n\nSearch a node by one of its properties. If the list contains extended standard nodes it is required to implement\na getter method like ''getFirstName'' or ''getFirstname''.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* `property` (string) - The nodes property to search in the value.\n* `value` (*) - The value to search in the given property.\n* `return` (node) - The node you searched or null if it can't be found.\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , User = require('<path>/User')\n , list = LinkedList.Create(User);\n\n ...\n list.searchBy('FirstName', \"Warden\");\n```\n\n<a name=\"get\">\n<h4>get(position[, raw])</h4>\n\nGet a node by a given position.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* `position` (number) - The position of the node that is wanted. If the position less equal '0' or higher than the list size\n the first or last node is returned.\n* `raw` (boolean) - A flag to get the node itself instead of the value only. Default is false to get only the value.\n* `return` (Node) - The node at the position or first/last node if the position is less/equal 0 or higher than list size.\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create();\n\n ...\n var node = list.get(54, true);\n```\n\n<a name=\"delete\">\n<h4>delete(position)</h4>\n\nDelete a node from given position.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* `position` (number) - The position of the node which has to be removed.\n* `return` (LinkedList) - The list itself is returned.\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create();\n\n ...\n list.delete(54, true);\n```\n\n<a name=\"first\">\n<h4>first()</h4>\n\nGet the first node of the list.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* `return` (node) - The first node in the list.\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create();\n\n ...\n var firstNode = list.first();\n```\n\n<a name=\"last\">\n<h4>last()</h4>\n\nGet the last node of the list.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* `return` (node) - The last node in the list.\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create();\n\n ...\n var firstNode = list.last();\n```\n\n<a name=\"isStdNode\">\n<h4>isStdNode(node)</h4>\n\nCheck if a node is an instance of the internal standard node.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* `node` (object) - The node that will be compared with the constructor of the standard node.\n* `return` (boolean) - True if the given node is a standard node. Otherwise false is returned.\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create();\n\n ...\n var node = ...;\n if (list.isStdNode(node)) {\n ...\n ...\n }\n```\n\n<a name=\"clean\">\n<h4>clean()</h4>\n\nRemoves all nodes from the list.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* `return` (LinkedList) - The list itself is returned.\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create();\n\n ...\n list.clean();\n```\n\n<a name=\"toArray\">\n<h4>toArray()</h4>\n\nConverts the list into an array.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* `return` (Array) - All nodes in an array.\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create();\n\n ...\n var nodes = list.toArray();\n ...\n```\n\n<h3>Iteration over the list</h3>\nTo reduce source code and do not lost performance it is recommended to iterate over the list itself\ninstead of use ''toArray'' and loop over this.\nThe ''LinkedList'' has the standard methods implemented you expect from an iterator.\n\n<a name=\"next\">\n<h4>next()</h4>\n\nGet the next node in the list.\n\n\n<a name=\"hasNext\">\n<h4>hasNext()</h4>\n\nCheck the existence of a next node.\n\n\n<a name=\"previous\">\n<h4>previous()</h4>\n\nGet the previous node in the list.\n\n\n<a name=\"hasPrevious\">\n<h4>hasPrevious()</h4>\n\nCheck the existence of a previous node.\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create()\n , node = null;\n // Traversing forwards \n for(node = list.first(); list.hasNext(); node = list.next()) {\n ... \n ... \n }\n \n // or backwards\n for(node = list.last(); list.hasPrevious(); node.previous()) {\n ... \n ... \n }\n```\n\n<h3>List node</h3>\n<a name=\"node\">\n<h4>node [Constructor]</h4>\n\nThe list node is the standard node object used by the linked list internally if no other node constructor is offered.\nYou can get it via the property 'node' of the linked list object.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* No arguments\n\n<b>Example</b>\n\n```javascript\nvar list = require(\"node-linkedlist\").Create()\n , node = list.node;\n\nvar newNode = node.Create();\n```\n\n<a name=\"setNext\">\n<h4>setNext(nextNode)</h4>\n\nSet another node object as next node to the current one.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* nextNode (object) - A node which has to be referenced as next node.\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create();\n... \nvar last = list.last()\n , node = list.node.Create();\n\nnode.setValue({\n field1: true, \n field2: 123, \n field3: {success: true}, \n field4: \"Everything's fine.\"\n});\n \nlast.setNext(node);\n...\n```\n\n<a name=\"next\">\n<h4>next()</h4>\n\nGet the next node that is referenced to the current node.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* No argument\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create();\n... \nvar node = list.first()\n...\nnode = node.next();\n...\n```\n\n<a name=\"hasNext\">\n<h4>hasNext()</h4>\n\nCheck the existence of a next nodes reference.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* No argument\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create();\n... \nvar node = list.first()\n...\nif (node.hasNext())\n node = node.next();\n...\n```\n\n<a name=\"setPrevious\">\n<h4>setPrevious(previousNode)</h4>\n\nSet another node object as previous node to the current one.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* previousNode (node) - The node which has to be referenced before current node.\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create()\n , node = list.node;\n...\nvar last = node.Create()\n , newNode = node.Create();\n\nlast.setValue({\n field1: true, \n field2: 123, \n field3: {success: true}, \n field4: \"Everything's fine.\"\n});\n\nnewNode.setValue(\"Only a small text string...\");\nlast.setPrevious(newNode);\n...\n```\n\n<a name=\"previous\">\n<h4>previous()</h4>\n\nGet the previous node that is referenced to the current node.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* No argument\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create();\n... \nvar node = list.last()\n...\nnode = node.previous();\n...\n```\n\n<a name=\"hasPrevious\">\n<h4>hasPrevious()</h4>\n\nCheck the existence of a previous nodes reference.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* No argument\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create();\n... \nvar node = list.last()\n...\nif (node.hasPrevious())\n node = node.previous();\n...\n```\n\n<a name=\"setValue\">\n<h4>setValue(value)</h4>\n\nSet the value that has to be added to the list. This method is used internally so it is fully transparent\nvia ''list.add(...)'' if you use the standard node.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* value (mixed) - The value that has to be put to a list via a node.\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create()\n , Node = list.node;\n... \nvar node = list.last()\n...\nvar newNode = Node.Create();\nnewNode.setValue({message: 'Created new node.'});\nnode.setNext(newNode);\n...\n```\n\n<a name=\"getValue\">\n<h4>getValue()</h4>\n\nGet the value that is stored in a node. This method is used internally so it is fully transparent\nvia ''list.get(position)'' if you use the standard node.\n<br/>\n<br/>\n<b>Arguments</b>\n\n* No argument\n\n<b>Example</b>\n\n```javascript\nvar LinkedList = require(\"node-linkedlist\")\n , list = LinkedList.Create()\n , Node = list.node;\n... \nvar node = list.last()\nconsole.log(node.getValue());\n...", | ||
| "readmeFilename": "README.md", | ||
| "gitHead": "b72a0f98fa7e861f2cf4ba0b88afebca71138e04", | ||
| "_id": "node-linkedlist@0.1.3", | ||
| "_shasum": "360b98756ff39c326a2b525e24857f91cc59ef2d", | ||
| "_from": "node-linkedlist@*" | ||
| } |
+39
-2
@@ -77,2 +77,39 @@ <h1>LinkedList</h1> | ||
| <a name="setitems"> | ||
| <h4>setItems(data[, callback])</h4> | ||
| Set a list of nodes. | ||
| <br/> | ||
| <br/> | ||
| <b>Arguments</b> | ||
| * `items` (array) - A list with single items to set as linked list. | ||
| * `callback` (function) - The callback function with parameter `err` and `listObj`. | ||
| * `return` (listObj) - The `LinkedList` instance itself. | ||
| <b>Example</b> | ||
| ```javascript | ||
| var LinkedList = require("node-linkedlist") | ||
| , list = LinkedList.Create() | ||
| , nodes = [ | ||
| {id: 23, ...}, | ||
| {id: 54, ...}, | ||
| {id: 43, ...}, | ||
| {id: 12, ...}, | ||
| {id: 87, ...} | ||
| ]; | ||
| ... | ||
| list.setItems(nodes, function(err, listObj) { | ||
| if (err) console.log(err); | ||
| else { | ||
| console.log(listObj.size); | ||
| // will output the number "5" | ||
| } | ||
| }); | ||
| ``` | ||
| <a name="add"> | ||
@@ -98,3 +135,3 @@ <h4>add(data[, callback])</h4> | ||
| ... | ||
| list.add('FirstName', function(err, listObj) { | ||
| list.add({"firstName": "Warden"}, function(err, listObj) { | ||
| if (err) console.log(err); | ||
@@ -128,3 +165,3 @@ else { | ||
| ... | ||
| list.searchBy('FirstName', "Warden"); | ||
| list.searchBy('firstName', "Warden"); | ||
| ``` | ||
@@ -131,0 +168,0 @@ |
+114
-67
@@ -6,3 +6,3 @@ var _node = require('./ListNode') | ||
| * | ||
| * @param dataClass | ||
| * @param {function} dataClass | ||
| * @constructor | ||
@@ -15,4 +15,5 @@ */ | ||
| this._dataType = null; | ||
| this._foundPosition = 0; | ||
| this.size = 0; | ||
| this.size = 0; | ||
| this.setDataType(dataClass); | ||
@@ -31,3 +32,3 @@ }; | ||
| * | ||
| * @param dataType | ||
| * @param {function} dataType | ||
| * @returns {LinkedList} | ||
@@ -40,3 +41,3 @@ */ | ||
| this._head = this._dataType.Create(); | ||
| this._head = _node.instance(); | ||
| return this; | ||
@@ -46,8 +47,35 @@ }; | ||
| /** | ||
| * | ||
| * @param {array} list | ||
| * @param {function} callback | ||
| * @returns {LinkedList} | ||
| */ | ||
| LinkedList.prototype.setItems = function(list, callback) { | ||
| list = list || null; | ||
| var me = this; | ||
| if(!Array.isArray(list)) { | ||
| callback({message: 'Error: This format is not supported yet. Array is currently the only type.', code: 0}, null); | ||
| return this; | ||
| } else if (list.length == 0) { | ||
| callback(null, me); | ||
| return me; | ||
| } else { | ||
| list.forEach(function(node) { | ||
| me.add(node, function() {}); | ||
| }); | ||
| callback(null, me); | ||
| return me; | ||
| } | ||
| }; | ||
| /** | ||
| * Add new list node. | ||
| * | ||
| * @param data {*} | ||
| * @param callback {function} | ||
| * @param {null|*} data | ||
| * @param {function} callback | ||
| * @return {LinkedList} | ||
| */ | ||
| LinkedList.prototype.add = function(data, callback) { | ||
| callback = callback || function(err, result) {}; | ||
| var me = this | ||
@@ -60,3 +88,3 @@ , node = null | ||
| } else if (me._dataType === _node) { | ||
| node = this._dataType.Create(); | ||
| node = this._dataType.instance(); | ||
| node.setValue(data); | ||
@@ -90,4 +118,4 @@ } else { | ||
| * | ||
| * @param property {string} | ||
| * @param value {*} | ||
| * @param {string} property | ||
| * @param {*} value | ||
| * @returns {object} | ||
@@ -99,7 +127,10 @@ */ | ||
| } else { | ||
| var currentItem = this._head.next() | ||
| var me = this | ||
| , currentItem = this._head.next() | ||
| , found = null; | ||
| me._foundPosition = 0; | ||
| /** | ||
| * Search a specific node by its property | ||
| * Search a node by its property. | ||
| */ | ||
@@ -111,28 +142,30 @@ var searchPropertyOfStandardNode = function() { | ||
| if (typeOfValue !== null) | ||
| switch(typeOfValue) { | ||
| case 'number': | ||
| case 'string': | ||
| case 'boolean': | ||
| while(currentItem !== null && currentItem.getValue()[property]) { | ||
| if (currentItem.getValue()[property] === value) { | ||
| found = currentItem; | ||
| break; | ||
| switch(typeOfValue) { | ||
| case 'number': | ||
| case 'string': | ||
| case 'boolean': | ||
| while(currentItem !== null && currentItem.getValue()[property]) { | ||
| if (currentItem.getValue()[property] === value) { | ||
| found = currentItem; | ||
| break; | ||
| } | ||
| currentItem = currentItem.next(); | ||
| me._foundPosition++; | ||
| } | ||
| currentItem = currentItem.next(); | ||
| } | ||
| break; | ||
| case 'function': | ||
| while(currentItem !== null && currentItem.getValue()[property]) { | ||
| if (currentItem.getValue()[property]() === value) { | ||
| found = currentItem; | ||
| break; | ||
| break; | ||
| case 'function': | ||
| while(currentItem !== null && currentItem.getValue()[property]) { | ||
| if (currentItem.getValue()[property]() === value) { | ||
| found = currentItem; | ||
| break; | ||
| } | ||
| currentItem = currentItem.next(); | ||
| me._foundPosition++; | ||
| } | ||
| currentItem = currentItem.next(); | ||
| } | ||
| break; | ||
| } | ||
| break; | ||
| } | ||
| }; | ||
| /** | ||
| * | ||
| * Search of a custom node. | ||
| */ | ||
@@ -142,4 +175,4 @@ var searchPropertyOfCustomNode = function() { | ||
| while(currentItem[method]) { | ||
| if ( (typeof currentItem[method] === 'function' && currentItem[method]() == value) || currentItem[method] == value) { | ||
| while(currentItem && currentItem[method]) { | ||
| if ( (typeof currentItem[method] === 'function' && (currentItem[method]() == value) || currentItem[method] == value)) { | ||
| found = currentItem; | ||
@@ -149,2 +182,3 @@ break; | ||
| currentItem = currentItem.next(); | ||
| me._foundPosition++; | ||
| } | ||
@@ -168,7 +202,7 @@ }; | ||
| /** | ||
| * Get a list node from a specific position. | ||
| * Get a node from a given position in the list. | ||
| * | ||
| * @param position | ||
| * @param raw | ||
| * @returns {null} | ||
| * @param {number} position | ||
| * @param {boolean} raw | ||
| * @returns {null|*} | ||
| */ | ||
@@ -182,3 +216,4 @@ LinkedList.prototype.get = function(position, raw) { | ||
| else { | ||
| var currentItem = this._head.next(), iterator = 0; | ||
| var iterator = 0; | ||
| currentItem = this._head.next(); | ||
| for(;iterator < position; iterator++) currentItem = currentItem.next(); | ||
@@ -192,5 +227,5 @@ } | ||
| /** | ||
| * Remove a list node by its position. | ||
| * Remove a node by its position in the list. | ||
| * | ||
| * @param position {number} | ||
| * @param {number} position | ||
| * @returns {LinkedList} | ||
@@ -200,28 +235,41 @@ */ | ||
| var node = this.get(position, true); | ||
| var buffer = node.previous(); | ||
| buffer.setNext(node.next()); | ||
| node.setPrevious(null).setNext(null); | ||
| if (position === this.size) this._last = buffer; | ||
| // Node is the first item in the list | ||
| if (node.previous() === null) { | ||
| // Node was the only one in the list. | ||
| if (node.next() === null) { | ||
| this._head.setNext(null); | ||
| node = null; | ||
| } else { | ||
| // Node has a following item. | ||
| var next = node.next(); | ||
| this._head.setNext(next); | ||
| next.setPrevious(this._head); | ||
| node = null; | ||
| if (position === this.size) this._last = next; | ||
| } | ||
| } else { | ||
| // Remove node from given position. | ||
| var buffer = node.previous(); | ||
| buffer.setNext(node.next()); | ||
| node.setPrevious(null).setNext(null); | ||
| if (position === this.size) this._last = buffer; | ||
| } | ||
| this.size--; | ||
| /** | ||
| * Test | ||
| */ | ||
| //var currentItem = this._head.next() | ||
| // , buffer = null | ||
| // , counter = 0; | ||
| //while(currentItem !== null) { | ||
| // counter++; | ||
| // buffer = currentItem; | ||
| // currentItem = currentItem.next(); | ||
| //} | ||
| // | ||
| //console.log(counter); | ||
| //console.log(buffer.getValue()); | ||
| return this; | ||
| }; | ||
| /** | ||
| * Get the position from last found node. | ||
| * On searching a node the position where it was found is stored and | ||
| * can be given back. | ||
| * | ||
| * @returns {number} | ||
| */ | ||
| LinkedList.prototype.getPosition = function() { | ||
| return this._foundPosition; | ||
| }; | ||
| /** | ||
| * Get the first list node. | ||
| * Get the first node in the list. | ||
| * | ||
@@ -284,3 +332,3 @@ * @returns {*} | ||
| * Check of the next node. | ||
| * @returns {*} | ||
| * @returns {boolean} | ||
| */ | ||
@@ -298,3 +346,3 @@ LinkedList.prototype.hasNext = function() { | ||
| * | ||
| * @returns {*} | ||
| * @returns {boolean} | ||
| */ | ||
@@ -312,3 +360,3 @@ LinkedList.prototype.hasPrevious = function() { | ||
| * @param node | ||
| * @returns {*} | ||
| * @returns {boolean} | ||
| */ | ||
@@ -321,3 +369,3 @@ LinkedList.prototype.isStdNode = function(node) { | ||
| * Remove all nodes from list. | ||
| * @returns {boolean} | ||
| * @returns {LinkedList} | ||
| */ | ||
@@ -358,5 +406,4 @@ LinkedList.prototype.clean = function() { | ||
| * Create a new instance of the list. | ||
| * @param classConstructor | ||
| * @param {function} classConstructor | ||
| * @returns {LinkedList} | ||
| * @constructor | ||
| */ | ||
@@ -363,0 +410,0 @@ LinkedList.Create = function(classConstructor) { |
+17
-13
@@ -9,2 +9,3 @@ var ListNode = function() { | ||
| /** | ||
| * Set the node value. | ||
| * | ||
@@ -18,4 +19,5 @@ * @param value | ||
| /** | ||
| * Get the node value. | ||
| * | ||
| * @returns {null} | ||
| * @returns {null|*} | ||
| */ | ||
@@ -25,8 +27,9 @@ ListNode.prototype.getValue = function() { | ||
| }; | ||
| /** | ||
| * Set a specific object to be the previous object in a chain. | ||
| * | ||
| * @param previousNode {ListNode} | ||
| * @returns {ListNode} | ||
| */ | ||
| /** | ||
| * Set a node object to be the previous object of the current one. | ||
| * | ||
| * @param {ListNode} previousNode | ||
| * @returns {ListNode} | ||
| */ | ||
| ListNode.prototype.setPrevious = function(previousNode) { | ||
@@ -47,5 +50,5 @@ this._previous.data = previousNode; | ||
| /** | ||
| * Set a specific object to be the next in the chain. | ||
| * Set a node object to be the next in the list. | ||
| * | ||
| * @param nextNode {ListNode} | ||
| * @param {ListNode} nextNode | ||
| * @returns {ListNode} | ||
@@ -59,3 +62,3 @@ */ | ||
| /** | ||
| * Get the next object in the chain. | ||
| * Get the next object in the list. | ||
| * | ||
@@ -70,2 +73,3 @@ * @returns {ListNode} | ||
| /** | ||
| * Check if the current node has a previous one. | ||
| * | ||
@@ -80,3 +84,3 @@ * @returns {boolean} | ||
| /** | ||
| * | ||
| * Check if the current node has a next one. | ||
| * @returns {boolean} | ||
@@ -89,7 +93,7 @@ */ | ||
| /** | ||
| * Create a new node instance. | ||
| * | ||
| * @returns {ListNode} | ||
| * @constructor | ||
| */ | ||
| ListNode.Create = function() { | ||
| ListNode.instance = function() { | ||
| return new ListNode(); | ||
@@ -96,0 +100,0 @@ }; |
@@ -28,3 +28,3 @@ var async = require('async') | ||
| // Create a new standard node object. | ||
| var node = list.node.Create(); | ||
| var node = list.node.instance(); | ||
@@ -61,2 +61,2 @@ // Set new node value. | ||
| }); | ||
| }); | ||
| }); |
@@ -0,0 +0,0 @@ var async = require('async') |
@@ -11,3 +11,3 @@ var async = require('async') | ||
| , User = require('./User') | ||
| , user = User.Create() | ||
| , user = User.instance() | ||
| ; | ||
@@ -26,3 +26,3 @@ | ||
| function iterator(node, innerCallback) { | ||
| var user = User.Create(); | ||
| var user = User.instance(); | ||
| user | ||
@@ -29,0 +29,0 @@ .setId(node.id) |
@@ -11,3 +11,3 @@ var async = require('async') | ||
| , User = require('./User') | ||
| , user = User.Create(); | ||
| , user = User.instance(); | ||
@@ -24,3 +24,3 @@ describe('Test search functionality', function(done) { | ||
| function iterator(node, innerCallback) { | ||
| var user = User.Create(); | ||
| var user = User.instance(); | ||
| user | ||
@@ -27,0 +27,0 @@ .setId(node.id) |
@@ -11,3 +11,3 @@ var async = require('async') | ||
| , User = require('./User') | ||
| , user = User.Create(); | ||
| , user = User.instance(); | ||
@@ -24,3 +24,3 @@ describe('Test traversing functionality', function(done) { | ||
| function iterator(node, innerCallback) { | ||
| var user = User.Create(); | ||
| var user = User.instance(); | ||
| user | ||
@@ -27,0 +27,0 @@ .setId(node.id) |
@@ -0,0 +0,0 @@ var async = require('async') |
@@ -0,0 +0,0 @@ var async = require('async') |
@@ -0,0 +0,0 @@ var async = require('async') |
@@ -0,0 +0,0 @@ var async = require('async') |
+1
-1
@@ -141,3 +141,3 @@ var User = function() { | ||
| */ | ||
| User.Create = function() { | ||
| User.instance = function() { | ||
| return new User(); | ||
@@ -144,0 +144,0 @@ }; |
+0
-0
@@ -0,0 +0,0 @@ var ring = require('ring'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
62819
29.25%1154
7.15%582
6.79%