1.0.9
Method to know the size (the number of elements) of our list. O(1)
number
:
size, with size >= 0.
Returns the first element in the list that returns true in the condition passed through the anonimus function. O(n)
(function)
an anonimus function with one argument that
must return a boolean, true if the element is
the desire element, false otherwise.
Object
:
the element found or null if no element returned true in
the condition.
var l = new List();
var item = {
x:1,
y:3
}
l.add(item);
console.log(l.findOne(e=>e.y==3));
Returns all the elements in the list that returns true in the condition passed through the anonimus function. O(n)
(function)
an anonimus function with one argument that
must return a boolean, true if the element is
the desire element, false otherwise.
Array
:
an array with all the elements found that returned true on
the condition.
var l = new List();
var item = {
x:1,
y:3
}
l.add(item);
var item2 = {
x:19,
y:3
}
l.add(item2);
console.log(l.find(e=>e.y==3));
Extends List
(Array
= []
)
the list is instantiated with an empty list unless
an Array is passed as parameter.
Returns the first element in the list that returns true in the condition passed through the anonimus function. O(n)
(function)
an anonimus function with one argument that
must return a boolean, true if the element is
the desire element, false otherwise.
Object
:
the element found or null if no element returned true in
the condition.
var l = new List();
var item = {
x:1,
y:3
}
l.add(item);
console.log(l.findOne(e=>e.y==3));
Returns all the elements in the list that returns true in the condition passed through the anonimus function. O(n)
(function)
an anonimus function with one argument that
must return a boolean, true if the element is
the desire element, false otherwise.
Array
:
an array with all the elements found that returned true on
the condition.
var l = new List();
var item = {
x:1,
y:3
}
l.add(item);
var item2 = {
x:19,
y:3
}
l.add(item2);
console.log(l.find(e=>e.y==3));
(Array
= []
)
the tree is instantiated with an empty tree unless
an Array is passed as parameter.
(function
= (a,b)=>a==b?0:a>b?1:-1
)
the function
that will be used.
Method to know the size (the number of elements) of our tree. O(1)
number
:
size, with size >= 0.
forEach implementation for tree, it can go through the tree in bfs or dfs but it will do it in dfs inorder if there is no argument, ie the tree will be travel in order from lower to higer. O(n)
Goes through the tree in dfs in preorder. O(n)
Returns an array with the elements in order (lower to higher). O(n)
any
:
an array with the elements.
Removes all elements from the tree. O(1)
Returns a copy which is a different instance from the original tree. O(n^2)
Extends BinaryTree
(Array
= []
)
the tree is instantiated with an empty unless an
Array is passed as parameter.
(function
= (a,b)=>a==b?0:a>b?1:-1
)
the function
that will be used.
Extends BinaryTree
(function
= (a,b)=>a==b?0:a>b?1:-1
)
the function
that will be used.
Adds an couple of key and value. There are no repeated keys, if two elements have the same keys the value will be updated. Since this is a tree the elements will be order using the keys. O(n)
Returns a copy which is a different instance from the original tree. O(n^2)
Extends AVLTree
(function
= (a,b)=>a==b?0:a>b?1:-1
)
the function
that will be used.
Adds an couple of key and value. There are no repeated keys, if two elements have the same keys the value will be updated. Since this is a tree the elements will be order using the keys. O(log n)
Returns a copy which is a different instance from the original tree. O(n)