数据结构
1、哈希表
class HashTable {
constructor() {
this.hashTable = new Object();
this.size = 0;
}
_hasKey(key) { // private fucntion
return (key in this.hashTable);
}
add(key, value) {
if(!this._hasKey(key)) {
this.hashTable[key] = value;
this.size++;
}
}
remove(key) {
if(this._hasKey) {
delete this.hashTable[key];
this.size--;
}
}
getValue(key) {
if(this._hasKey(key)) {
return this.hashTable[key];
}
return null;
}
getSize() {
return this.size;
}
clear() {
this.hashTable = new Object();
this.size = 0;
}
}2、队列
3、栈
4、链表
5、双向链表
6、二叉树和平衡二叉树

7、本节源码
8、参考文档
Last updated