Methods
findNodes(data, keys) → {Array}
find nodes which key matches in the given keys array.
n is the number of element in data, m is the number of key.
In List, it traverse the iterator. so, time complexity is O(nm).
In others, it use equalRange Method in tree. so, time complexity is O(mlog(n)).
Working container : List, setTree, multiSetTree, mapTree, multiMapTree.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | iterable container in this data structure. |
keys |
Array | find datas. |
Returns:
array of nodes whick match the key.
- Type
- Array
map(data, func)
apply the given function to elements in the given object.
It cannot apply to set as set is key and data are equal and it is sorted by key.
it traverse nodes by iterator and check condition.
it takes time about O(n).
Working container : List, mapTree, multiMapTree.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | List, MapTree, MultiMapTree |
func |
function | apply this function to elements in object. |
mergeSort(data, comp)
merge sort iterable data with compare function.
reference https://en.wikipedia.org/wiki/Merge_sort.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | iterable object |
comp |
function | compare function |
quickSort(data, comp)
quick sort by compare function
Reference https://en.wikipedia.org/wiki/Quicksort.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | iterable object |
comp |
function | compare function |
removeCondition(data, condition) → {boolean}
remove all elements which match the condition in container.
it traverse nodes by iterator and check condition.
it takes time about O(n). But in tree, when you erase node, the erase time takes O(log(n))
Working container : List, setTree, multiSetTree, mapTree, multiMapTree.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | iterable container in this data structure. |
condition |
function | check data or key match the condition. |
Returns:
- Type
- boolean
unique(data)
make a given data container have unique elements.
it traverse nodes by iterator and check condition.
it takes time about O(n).
Working container : List, multiSetTree, multiMapTree.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | iterable container in this data structure. |