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;
} ........
}

最新文章

  1. 机器学习笔记——支持向量机 (SVM)
  2. angular学习的一些小笔记(中)之基础ng指令
  3. Android系统启动分析(Init-&gt;Zygote-&gt;SystemServer-&gt;Home activity)
  4. bootstrap ace MVC
  5. CentOS学习笔记--SCSI 设备热插拔
  6. 深入理解javascript:揭秘命名函数表达式
  7. UITextField控件处理键盘弹出时遮住输入框的问题
  8. 把int类型值转换成int数组(不通过string类型转换)
  9. 【原创】leetCodeOj --- Candy 解题报告
  10. 1599: [Usaco2008 Oct]笨重的石子
  11. Java文件流应用:剪切文件
  12. Codeforces Round #549 (Div. 2) 训练实录 (5/6)
  13. mybatis 中使用 in 查询
  14. 男默女泪,ArcGIS AddIN 编辑逻辑赏析,走过路过,不要错过
  15. Linux上的10个Touch命令实例
  16. Excel组合图表快速制作小功能
  17. https及证书
  18. 解析xml文件 selectSingleNode取不到节点
  19. Cnblog-Latex数学公式使用测试
  20. Mac + OpenCV3.3.0 + PyCharm (非常简单的配置过程)

热门文章

  1. cocos2dx 2.2.3编译第一个apk到安卓手机
  2. Echarts Binning on map 根据真实经纬度渲染数据
  3. 【Android】Android输入子系统【转】
  4. input keyevent发送按键值【转】
  5. uva1560
  6. [转]Linux系统调用--fcntl函数详解
  7. hdu6198 number number number(递推公式黑科技)
  8. map Codeforces Round #Pi (Div. 2) C. Geometric Progression
  9. 线段树+树状数组+贪心 HDOJ 5338 ZZX and Permutations
  10. 转发:吐血总结,彻底明白 python3 编码原理