java学习_5_24
2024-09-30 20:15:42
TreeMap底层是用红黑树实现的,源码如下:
/**
* A Red-Black tree based {@link NavigableMap} implementation.
* The map is sorted according to the {@linkplain Comparable natural
* ordering} of its keys, or by a {@link Comparator} provided at map
* creation time, depending on which constructor is used.
*
* <p>This implementation provides guaranteed log(n) time cost for the
* {@code containsKey}, {@code get}, {@code put} and {@code remove}
* operations. Algorithms are adaptations of those in Cormen, Leiserson, and
* Rivest's <em>Introduction to Algorithms</em>.
*/ static final class Entry<K,V> implements Map.Entry<K,V> {
K key;
V value;
Entry<K,V> left;
Entry<K,V> right;
Entry<K,V> parent;
boolean color = BLACK;
Set为一接口(没有顺序 不可重复),其实现类HashSet底层实现实为HashTable JDK源码如下:
public class HashSet<E>
extends AbstractSet<E>
implements Set<E>, Cloneable, java.io.Serializable
{
static final long serialVersionUID = -5024744406713321676L; private transient HashMap<E,Object> map; // Dummy value to associate with an Object in the backing Map
private static final Object PRESENT = new Object(); /**
* Constructs a new, empty set; the backing {@code HashMap} instance has
* default initial capacity (16) and load factor (0.75).
*/
public HashSet() {
map = new HashMap<>();
} .............
public boolean add(E e) {
return map.put(e, PRESENT)==null;
} ........
}
最新文章
- 机器学习笔记——支持向量机 (SVM)
- angular学习的一些小笔记(中)之基础ng指令
- Android系统启动分析(Init->;Zygote->;SystemServer->;Home activity)
- bootstrap ace MVC
- CentOS学习笔记--SCSI 设备热插拔
- 深入理解javascript:揭秘命名函数表达式
- UITextField控件处理键盘弹出时遮住输入框的问题
- 把int类型值转换成int数组(不通过string类型转换)
- 【原创】leetCodeOj --- Candy 解题报告
- 1599: [Usaco2008 Oct]笨重的石子
- Java文件流应用:剪切文件
- Codeforces Round #549 (Div. 2) 训练实录 (5/6)
- mybatis 中使用 in 查询
- 男默女泪,ArcGIS AddIN 编辑逻辑赏析,走过路过,不要错过
- Linux上的10个Touch命令实例
- Excel组合图表快速制作小功能
- https及证书
- 解析xml文件 selectSingleNode取不到节点
- Cnblog-Latex数学公式使用测试
- Mac + OpenCV3.3.0 + PyCharm (非常简单的配置过程)
热门文章
- cocos2dx 2.2.3编译第一个apk到安卓手机
- Echarts Binning on map 根据真实经纬度渲染数据
- 【Android】Android输入子系统【转】
- input keyevent发送按键值【转】
- uva1560
- [转]Linux系统调用--fcntl函数详解
- hdu6198 number number number(递推公式黑科技)
- map Codeforces Round #Pi (Div. 2) C. Geometric Progression
- 线段树+树状数组+贪心 HDOJ 5338 ZZX and Permutations
- 转发:吐血总结,彻底明白 python3 编码原理