Collection集合汇总
List – 有序可重复列表ArrayList
底层是用数组实现的,重要的成员有 元素数组/数组中元素数 size/ modCount 修改次数
进行 add 添加时,若没有指定添加位置,就会根据 size 确定添加的新元素在数组中的下标进行添加,若 size >= 数组长度,则需要扩容
在进行扩容时,会将 modCount++,并且会将原数组中的元素,拷贝至新数组中,新数组的大小是原数组的 1.5 倍,默认的初始容量是 0,且在第一次添加元素时,设置数组大小为 10
若指定 i 为添加元素的位置,会调用 System.ArrayCopy 方法对 i 下标以后的元素进行拷贝,拷贝完成后再把添加的元素放在 i 位置
调用 get 方法时,由于 ArrayList 底层基于数组,因此实现了一个 RandomAccess 标识接口,表示按下标读取数据速度很快,主要是由于数组在内存中是连续存储,可以通过第一个元素的存储地址和偏移量offset 直接计算得到访问的元素的存储地址
若 contains 方法是通过元素的值进行查找,则需要遍历数组
Linke ...
Hello World
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick StartCreate a new post1$ hexo new "My New Post"
More info: Writing
Run server1$ hexo server
More info: Server
Generate static files1$ hexo generate
More info: Generating
Deploy to remote sites1$ hexo deploy
More info: Deployment