Constructor
new List(data)
- Version:
- v1.0.
Get null or iterable Object and make List sequentially.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
data |
null | object |
null
|
The data of iteable object. |
Methods
size() → {number}
Get the number of elements.
Returns:
the number of elements.
- Type
- number
empty() → {boolean}
Make sure the list is empty.
Returns:
if list is empty, true.
- Type
- boolean
front() → {boolean|*}
Get the first element of list.
Returns:
false if list is empty, else return the first element.
- Type
- boolean | *
back() → {boolean|*}
Get the last element of list.
Returns:
false if list is empty, else return the last element.
- Type
- boolean | *
begin() → {null|Node}
Get the first Node of list.
Can use getNext method for next node.
if list is empty, return null.
Returns:
The first Node of list.
- Type
- null | Node
end() → {Node}
Get the back end of list, nil.
For check of end.
Or use getPrev method for before node:last node of list.
Returns:
nil
- Type
- Node
rbegin() → {null|Node}
Get the last node of list.
Use the getPrev method for next node.
If list is empty, return null.
Returns:
last node of list.
- Type
- null | Node
rend() → {Node}
Get the front end of list, rnil
For check of the end of reverse iterator.
Use getNext method for get first node of list.
Returns:
rnil.
- Type
- Node
clear()
Make list empty.
insert(node, data) → {boolean|Node}
Insert new data in front of given node and return present node like c++ stl.
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | In front of this node, the data is inserted. |
data |
* | The data to insert list. |
Returns:
- If node is not Node object, return false, else return this node.
- Type
- boolean | Node
erase(node) → {boolean|Node}
Erase this node and return the next node.
Parameters:
Name | Type | Description |
---|---|---|
node |
* | The node which is removed from list. |
Returns:
- If node is not Node object, return false, else return the next node.
- Type
- boolean | Node
pushBack(data)
The data is added to end of list.
Parameters:
Name | Type | Description |
---|---|---|
data |
* | the data of list. |
pushFront(data)
The data is added to front of list.
Parameters:
Name | Type | Description |
---|---|---|
data |
* | the data of list. |
popBack() → {boolean}
The data is removed from end of list.
Returns:
false it the list is empty.
- Type
- boolean
popFront() → {boolean}
The data is removed from front of list.
Returns:
false it the list is empty.
- Type
- boolean
compare(data) → {boolean}
Compare iterable object with this list.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | iterable object. |
Returns:
- true if the data and index is same in list and iterable object.
- Type
- boolean
splice(node, data) → {boolean}
Insert elements of iterable object in list where the front of given node.
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | Elements of data are inserted in front of this node. |
data |
Object | iterable object |
Returns:
If elements are well inserted, return true.
- Type
- boolean
sort(comp, sorting)
sort the list by compare function. Basically quick sort, but can choose merge sort.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
comp |
function | compare function |
|
sorting |
string |
quicksort
|
sort mode |
merge(data, compare) → {boolean}
Merge this list and data(iterable object) by sequential order.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | sortable iterable object. |
compare |
function | inequality function. |
Returns:
check well merged.
- Type
- boolean
reverse()
Reverse the list.
toString() → {string}
show information of object
Returns:
- Type
- string
copy() → {List}
return the copy of this List
Returns:
- Type
- List