java数据结构
多多洛码代码
学生
展开
-
数据结构之HashMap1.8版本源码过程解析
HashMap源码过程解析 继承、实现关系 相关默认属性 默认初始容量:16 最大容量:1<<30 加载因子:0.75f 树化阈值:8 树退化阈值:6 static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; // aka 16 static final int MAXIMUM_CAPACITY = 1 << 30; static final float DEFAULT_LOAD_FACTOR = 0.75f; stat原创 2020-08-16 22:13:39 · 99 阅读 · 0 评论 -
数据结构Map之HashMap
HashMap key无序,唯一 value 无序,不唯一 线程不安全,效率高 允许key或值为null 底层 transient Node<K,V>[] table; // 数组 transient Node<K,V>[] table; // 链表 static class Node<K,V> implements Map.Entry<K,V>{ Node(int hash, K key, V value, Node<K,V> nex原创 2020-08-03 14:47:47 · 127 阅读 · 0 评论 -
数据结构List之ArrayList
ArrayList 数组形式,连续空间 优点:遍历 访问 效率高 缺点:删除 添加效率低,按内容查效率低 默认容量 DEFAULT_CAPACITY = 10 最大容量 private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; 其中 Integer.MAX_VALUE = 0x7fffffff; 添加数据 public boolean add(E e) { ensureCapacityInternal(size原创 2020-08-03 14:42:23 · 142 阅读 · 0 评论 -
数据结构List之LinkedList
LinkedList 存储方式 双向链表存储方式 优点:插入、删除效率高 缺点:遍历、查询较慢 结构 transient int size = 0; /** * Pointer to first node. * Invariant: (first == null && last == null) || * (first.prev == null && first.item != null) *原创 2020-08-03 14:41:15 · 129 阅读 · 0 评论