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