7 Star 34 Fork 23

空無一悟/algorithms

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
BSTMap.java 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
空無一悟 提交于 2021-09-22 23:47 +08:00 . init
/***********************************************************
* @Description : 基于支持键值对的BSTKV实现地Map,效率要更高。
* 第1节实现地BST只支持传入一个1个E,为了支持传入键值对,所以用其他的实现了
* 比如玩转数据结构C++版里写的 Chapter06BST.Part1BasicChapter05BST.BST
* @author : 梁山广(Laing Shan Guang)
* @date : 2018/5/17 23:46
* @email : liangshanguang2@gmail.com
***********************************************************/
package Chapter07SetAndMap.Section7BSTMap;
import Chapter06BST.BSTKV;
import Chapter07SetAndMap.Section5MapBasic.Map;
public class BSTMap<Key extends Comparable<Key>, Value> implements Map<Key, Value> {
private BSTKV<Key, Value> bst;
public BSTMap() {
bst = new BSTKV<>();
}
@Override
public void set(Key key, Value value) {
bst.add(key, value);
}
@Override
public void delete(Key key) {
bst.remove(key);
}
@Override
public boolean contains(Key key) {
return bst.contains(key);
}
@Override
public Value get(Key key) {
return bst.get(key);
}
@Override
public int getSize() {
return bst.getSize();
}
@Override
public boolean isEmpty() {
return bst.isEmpty();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lsgwr/algorithms.git
git@gitee.com:lsgwr/algorithms.git
lsgwr
algorithms
algorithms
master

搜索帮助