Constructor
new LinkedList()
Example
var ll = new LinkedList ();
Methods
(static) append(value)
This method is used to append value at the end of double Linked list.
Example
var dl = new DoubleLinkedList ();
dl.append(1);
dl.append(2);
dl.append(3);
Parameters:
| Name | Type | Description |
|---|---|---|
value |
undefined | The value to be appended to this double Linked list. |
(static) append(value)
This method is used to append value at the end of Linked list.
Example
var ll = new LinkedList ();
ll.append(1);
ll.append(2);
ll.append(3);
Parameters:
| Name | Type | Description |
|---|---|---|
value |
undefined | The value to be appended to this Linked list. |
(static) find(value) → {Boolean}
This method is used to find node that has value in this Linked list.
Example
var ll = new LinkedList ();
var ret1 = ll.find(1); // ret1 = false
ll.append(1);
ll.append(2);
var ret2 = ll.find(1); // ret2 = false
Parameters:
| Name | Type | Description |
|---|---|---|
value |
undefined | The position which want to get value from Linked list. |
Returns:
This method returns ‘true’ if this Linked list has value or ‘false’ if this Linked list doesn't have value.
- Type
- Boolean
(static) getNode(position) → {Node}
This method is used to find node in the Linked list in the index of position.
Example
var ll = new LinkedList ();
ll.append(1);
ll.append(2);
ll.append(3);
Node node = ll.getNode(1);
Parameters:
| Name | Type | Description |
|---|---|---|
position |
Number | The position which want to get node from this Linked list. |
Returns:
This method returns the node from the specified position from this Linked list.
- Type
- Node
(static) indexOf(value) → {Number}
This method is used to get the index of value from this Linked list, but does not remove.
Example
var ll = new LinkedList ();
ll.append(1);
ll.append(2);
ll.append(3);
var ret = ll.indexOf(2); // ret = 1
Parameters:
| Name | Type | Description |
|---|---|---|
value |
undefined | The value which want to get index from this Linked list. |
Throws:
This method returns null if this Linked list doesn't have specified value.
Returns:
This method returns index of value in this Linked list.
- Type
- Number
(static) insert(pos, value)
This method is used to insert value at the specified position of Linked list.
Example
var ll = new LinkedList ();
ll.append(1);
ll.append(3);
ll.insert(2,1);
Parameters:
| Name | Type | Description |
|---|---|---|
pos |
Number | The position to be appended value in this Linked list. |
value |
undefined | The value to be appended to this Linked list. |
Throws:
This method returns 'false' if cannot insert value at the specified position in this Linked list.
(static) isEmpty() → {Boolean}
This method is used to check if this Linked list is empty.
Example
var ll = new LinkedList ();
var ret1 = ll.isEmpty(); // ret1 = true;
ll.append(1);
ll.append(3);
var ret2 = ll.isEmpty(); // ret2 = false
Returns:
This method returns ‘true’ if this Linked list is empty or ‘false’ if this Linked list is not empty.
- Type
- Boolean
(static) remove()
This method is used to remove the specified value from this Linked list.
Example
var ll = new LinkedList ();
ll.append(1);
ll.append(3);
ll.remove(1); // 1 will be removed.
Throws:
This method returns null if the value of the specified position in this Linked list is empty.
(static) removeAt() → {undefined}
This method is used to remove the value of specified position from this Linked list.
Example
var ll = new LinkedList ();
ll.append(1);
ll.append(3);
ll.removeAt(0); // 1 will be removed.
Throws:
This method returns null if the value of the specified position in this Linked list is empty.
Returns:
This method returns the value of specified position in this Linked list.
- Type
- undefined
(static) size() → {Number}
This method is used to get the number of values in this Linked list.
Example
var ll = new LinkedList ();
ll.append(1);
ll.append(3);
var size = ll.size(); // ret = 2
Returns:
This method returns the number of values in this Linked list.
- Type
- Number
(static) toString() → {String}
This method is used to get values of this Linked list.
Example
var ll = new LinkedList ();
ll.append(1);
ll.append(3);
var v = ll.toString(); // v = 1, 3
Returns:
This method returns the String which has value of this Linked list.
- Type
- String