TreeList

Kind: global class

new TreeList(comparator, root)

Param Default Description
comparator   the comparator function
root the root element Comparator working :- 1. The comparator returns -1 if the new node is lesser than the previous node 2. The comparator returns 0 if the new node is equal to the previous node 3. The comparator returns 1 if the new node is greater than the previous node

treeList.push(new_ele) ⇒

Method appends a new element to the list

Kind: instance method of TreeList
Returns: boolean returns true if the insertion is successful

Param Description
new_ele the new element to be inserted in the list

treeList.remove(ele) ⇒

Removes the given element from the list

Kind: instance method of TreeList
Returns: TreeNode the removed element

Param Description
ele The TreeNode that is to be removed

treeList.pop() ⇒

Method removes the element at the end of the list

Kind: instance method of TreeList
Returns: TreeNode the removed element

treeList.shift() ⇒

Method removes the element at the start of the list

Kind: instance method of TreeList
Returns: TreeNode the removed element

treeList.contains() ⇒

Method checks if the element is in the list

Kind: instance method of TreeList
Returns: boolean true, if the element is present in the list

treeList.indexOf() ⇒

Method returns the index of the given element, or -1 if the element is not present.

Kind: instance method of TreeList
Returns: int the index of the given element

treeList.lastIndexOf() ⇒

Method returns the last index of the given element, or -1 if the element is not present.

Kind: instance method of TreeList
Returns: int the last index of the given element

treeList.forEach(consumer)

Method iterates through each of the element present in the list, with the give consumer function

Kind: instance method of TreeList

Param Description
consumer function that iterates through each of the element in the list

treeList.join(delimiter) ⇒

Method creates and returns a new string by concatenating all of the elements in an array

Kind: instance method of TreeList
Returns: String a string with all elements joined with the delimiter

Param Default Description
delimiter , the delimiter for joining the elements in the string

treeList.filter(predicate) ⇒

Method takes in a predicate function, and returns a filtered array.

Kind: instance method of TreeList
Returns: Array an array with all the elements that are accepted by the predicate

Param Description
predicate the predicate function, should return true if the element is to be present in the new array

treeList.map(consumer) ⇒

Method takes in a consumer function, and returns an array consisting of the results of applying the given function to the elements of the list.

Kind: instance method of TreeList
Returns: Array an array with all the new elements values

Param Description
consumer the consumer function, that returns the new value of the node data

treeList.toArray() ⇒

Method returns the contents of the list as an array

Kind: instance method of TreeList
Returns: Array the contents of the list

treeList.reduce(reducer, initial_value) ⇒

The reduce() method executes a reducer function (that you provide) on each member of the array resulting in a single output value.

Kind: instance method of TreeList
Returns: Object the final value

Param Description
reducer the reducer function
initial_value the initial value

treeList.every(callback) ⇒

The every() method tests whether all elements in the array pass the test implemented by the provided function.

Kind: instance method of TreeList
Returns: boolean true if all elements pass the test

Param Description
callback the callback

treeList.some(callback) ⇒

The some() method tests whether at least one element in the array passes the test implemented by the provided function.

Kind: instance method of TreeList
Returns: boolean true if all elements pass the test

Param Description
callback the callback

treeList.find(callback) ⇒

The find() method returns the value of the first element in the array that satisfies the provided testing function.

Kind: instance method of TreeList
Returns: Object the element if found, else undefined

Param Description
callback the callback

treeList.concat(array)

Method merges the given array with the list.

Kind: instance method of TreeList

Param Description
array the array to be merged

TreeList.comparator(curr_ele, new_ele) ⇒

The default comparator, sorts the elements in ascending order

Kind: static method of TreeList
Returns: int returns +1 if the new element is to be placed right to the current element, -1 if the new element is to be placed to the left of the current element and 0 if the elements are equal.

Param Description
curr_ele the previous element
new_ele current element

TreeList.leftMost(node)

Method returns the left most node with reference to the current node.

Kind: static method of TreeList

Param Description
node the node with reference to which the current node is to be found out.