All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Explicit export package public interface
- Iterable mixin to transform linear data structure iterable
BinaryTreeNode (BTNode) is used as a node for binary trees to creates a dynamic linked representation of the tree, it is the root of binary trees.
Note: BTNode can't be manipulated directly only through BinaryTree.root getter
Properties:
data- Node's datafather- Node's father which is a node as wellleft- Left subtree noderight- Right subtree nodebrother- Brother subtree node, which means right subtree when is left subtree and vice-versaroot- Root from the node, it walks through the ancestors until it find the its root
Methods:
setLeft(): this- creates a leaft to insert data in, for tree with no left sonsetRight(): this- returns true whether tree is right subtree or false otherwiseisRoot(): boolean- Checks whether the tree is the root nodeisLeft(): boolean- returns true whether tree is left subtree or false otherwiseisRight(): boolean- creates a leaf to insert data in, for tree with no right sonisLeaf(): boolean- returns true whether tree has no sons, also known as a leaflevel(): number- Calculates the level of the subtreeancestor(): boolean- Checks whether the tree is ancestor of the treedescendant(): boolean- Checks whether the tree is the root node
- Construct tree with options
rootandcomparator, comparator by default is a plain equalitya < bcomparison androotcreates a binary tree with root value
Properties:
data: T | undefined- root data if existsroot: BTNode- root nodeleft: BTNode- left subtreeright: BTNode- right subtreelength: number- size of the tree
Methods:
empty(): boolean- alias for.lengthclear(): this- remove all data from the treedepth(): number- returns the longest path in the tree, which means the highest level or-Infinityif is emptyinsert(...items): this- insert multiple data in the tree following the constructor optioncomparatorwhich when is true insert at the left and right otherwiseinsertDistinct(...items): this- same as.insertbut ignores equal values usingObject.iscomparison
- Add the following methods:
peak(): T- Retrieve the first element from the queue, the next to be removed, or throwsQueueUnderflowexception if is emptyclear- remove all elements from the collection
-
Add the following methods:
clear(): this- remove all elements from the collection[Symbol.iterator]- iteratorentries(): IterableIterator<[number, T]>- Returns an iterable of key, value pairs for every entry in collectionkeys(): IterableIterator<number>- Returns an iterable of keys in the collectionvalues(): IterableIterator<T>- Returns an iterable of values in the collection
-
Add LinkedList data structure with no limit of size. It has also some exceptions that can be throwed
-
Add methods to LinkedList:
pop,push,size,isEmpty,length,size,indexOf,toArray,dequeue,clear,peek,tailandcontains. -
Besides the methods above. Add
values,entries(as the default) andvaluesiterators to LinkedList the same as theArrayhas
0.4.0 - 2021-09-30
-
Add Stack data structure get LIFO access:
push- Insert item at the beginning of the stackpop- Remove the last item insertedtop- Returns the top of the stacksize- Returns the size of the stackempty- Return true of false depending whether or not the stack contains any itemslength- Alias forsize
-
Add Queue data structure to get FIFO access
insert- Insert several items in the queue, which can grow indefinitelyremove- Remove the last first element inserted, applied when the queue is nonemptyempty- return true of false depending whether or not the queue contains any itemssize- returns the length of the queueclear- remove all elements