jstructures

0.8.2

AVL

AVL 类(AVL 树, 继承自 BST)

new AVL(): AVL

Extends BST

Returns
AVL: Instance
Static Members
balanced(x, 要判断的节点)
AVLBalanced(x, 要判断的节点)
balFac(x, 要判断的节点)
height(x, 要判断的节点)
Instance Members
insert(e)
remove(e)

BST

BST 类(二叉搜索树类, 继承自 BinTree)

new BST(): BST

Extends BinTree

Returns
BST: Instance
Static Members
removeAt(x)
searchIn(v, e, parent, p)
Instance Members
search(e)
insert(e)
remove(e)

BinNode

BinNode 类(二叉树节点类)

new BinNode(e: Anyone, parent: BinNode, lc: BinNode, rc: BinNode): BinNode
Parameters
e (Anyone = null)
parent (BinNode = null) 父节点
lc (BinNode = null) 左子节点
rc (BinNode = null) 右子节点
Returns
BinNode: Instance
Static Members
travLevel(p, visit, 访问函数)
travPre(p, visit, 访问函数)
travIn(p, visit, 访问函数)
travPost(p, visit, 访问函数)
swap(node1, node2)
Instance Members
data
parent
lc
rc
height
size
isRoot
isLChild
isRChild
hasParent
hasLChild
hasRChild
hasChild
hasBothChild
isLeaf
sibling
uncle
fromParentTo
pred
succ
insertAsLC(e)
insertAsRC(e)

BinTree

BinTree 类(二叉树类)

new BinTree(): BinTree
Returns
BinTree: Instance
Instance Members
size
size
empty
root
root
updateHeightAbove(p)
insertAsRoot(e)
insertAsLC(p, e)
insertAsRC(p, e)
attachAsLC(p, s)
attachAsRC(p, s)
remove(p)
secede(p)
travLevel(visit, 访问函数)
travPre(visit, 访问函数)
travIn(visit, 访问函数)
travPost(visit, 访问函数)

Heap

Heap 堆

new Heap(elems: any, length: any): Heap
Parameters
elems (any = [])
length (any = 0)
Returns
Heap: Instance
Instance Members
size
percolateUp
percolateDown
insert(e)
getMax()
delMax(e)

properParent

得到父子三者(最多三个) 中的最大值

properParent
Parameters
n (any)
i (any)

ListNode

ListNode 类

new ListNode(e: Anyone?): ListNode
Parameters
e (Anyone?) 初始数组
Returns
ListNode: Instance
Instance Members
insertAsSucc(e)
insertAsPred(e)

List

Linked-list 类

new List(_elem: Array): List
Parameters
_elem (Array) 初始数组
Returns
List: Instance
Instance Members
size
first
last
insertAsFirst(e)
insertAsLast(e)
insertA(p, e)
insertB(p, e)
remove(p)
disordered()
findElem(e, n, p)
search(e, n, p)
deduplicate()
uniquify()
traverse(visit)
valid(p)
selectMax(p, n)
insertionSort(p, n)
selectionSort(p, n)
merge(p, n, he, q, m)
mergeSort(p, n)

Queue

Queue 类

new Queue(): Queue
Returns
Queue: Instance
Instance Members
enqueue(e)
dequeue()
front
empty
size

SegmentTree

Segment-tree 线段树(区间树)类

new SegmentTree(data: any, mergeFn: any, _elem: Array): List
Parameters
data (any)
mergeFn (any)
_elem (Array) 初始数组
Returns
List: Instance
Instance Members
size
leftChild(index)
rightChild(index)
build(index, left, right)
query(qL, qR)
update(index, val)

Stack

Stack 类

new Stack(): Stack
Returns
Stack: Instance
Instance Members
push(e)
pop()
top
empty
size

Trie

new Trie(): Trie
Returns
Trie: Instance
Instance Members
size
root
insert(word)
find(word)

UnionFind

UnionFind 并查集类

new UnionFind(size: Number): UnionFind
Parameters
size (Number) 集合规模
Returns
UnionFind: Instance
Instance Members
find(p)
union(p, q)
isConnected(p, q)
toString()

Vector

new Vector(_elem: Array): Vector
Parameters
_elem (Array = []) 初始数组
Returns
Vector: Instance
Static Members
binSearch(_elem, e, lo, hi)
bubbleSort(_elem, lo, hi)
merge(_elem, lo, mi, hi)
mergeSort(_elem, lo, hi)
Instance Members
size
insert(r, e)
removeRange(lo, hi)
remove(r)
disordered()
findElem(e, lo, hi)
search(e, lo, hi)
deduplicate()
uniquify()
traverse(visit)