当前位置: 首页 > news >正文

网站icp不备案有关系吗桂林官网

网站icp不备案有关系吗,桂林官网,网站平台建设框架,oa系统服务器地址在哪里看#来自ゾフィー(佐菲) 1 简介 LinkedList 的底层数据结构是双向链表。可以当作链表、栈、队列、双端队列来使用。有以下特点: 在插入或删除数据时,性能好;允许有 null 值;查询效率不高;线程不安…

#来自ゾフィー(佐菲)

1 简介

LinkedList 的底层数据结构是双向链表。可以当作链表、栈、队列、双端队列来使用。有以下特点:

  • 在插入或删除数据时,性能好;
  • 允许有 null 值;
  • 查询效率不高;
  • 线程不安全;
public class LinkedList<E>extends AbstractSequentialList<E>implements List<E>, Deque<E>, Cloneable, java.io.Serializable
{}

2 源码

LinkedList 数据结构:

private static class Node<E> {E item; //结点值Node<E> next; //后驱节点Node<E> prev; //前驱节点Node(Node<E> prev, E element, Node<E> next) {this.item = element;this.next = next;this.prev = prev;}
}

LinkedList 两个构造函数:

public LinkedList() {}public LinkedList(Collection<? extends E> c) {this();addAll(c);
}

addAll()

 public boolean addAll(int index, Collection<? extends E> c) {//校验 index 是否合理checkPositionIndex(index);Object[] a = c.toArray();int numNew = a.length;if (numNew == 0)return false;//succ:待添加节点的位置。//pred:待添加节点的前驱节点。  Node<E> pred, succ;if (index == size) {//在末尾插入succ = null;pred = last;} else { //不在末尾插入succ = node(index); //这个方法 会折半pred = succ.prev;}for (Object o : a) {//创建新节点@SuppressWarnings("unchecked") E e = (E) o;Node<E> newNode = new Node<>(pred, e, null);if (pred == null)first = newNode;elsepred.next = newNode;pred = newNode;}if (succ == null) {last = pred;} else {pred.next = succ;succ.prev = pred;}//把集合的大小设置为新的大小 size += numNew;modCount++;return true;}

get() -> 会有折半

public E get(int index) {//校验 index 是否越界checkElementIndex(index);return node(index).item;
}Node<E> node(int index) {// assert isElementIndex(index);//分一半查找if (index < (size >> 1)) {Node<E> x = first;for (int i = 0; i < index; i++)x = x.next;return x;} else {Node<E> x = last;for (int i = size - 1; i > index; i--)x = x.prev;return x;}}

add()

public boolean add(E e) {//在末尾追加元素的方法。linkLast(e);return true;
}void linkLast(E e) {final Node<E> l = last;final Node<E> newNode = new Node<>(l, e, null);last = newNode;if (l == null) //为空链表first = newNode;elsel.next = newNode;size++;//size 自增modCount++;
}

remove()

public boolean remove(Object o) {if (o == null) {for (Node<E> x = first; x != null; x = x.next) {if (x.item == null) {//移除节点unlink(x);return true;}}} else {for (Node<E> x = first; x != null; x = x.next) {if (o.equals(x.item)) {unlink(x);return true;}}}return false;
}//删除节点
E unlink(Node<E> x) {// assert x != null;final E element = x.item;final Node<E> next = x.next;final Node<E> prev = x.prev;//1 -> 2 -> 3      1 -> 3if (prev == null) { //移除的是头节点first = next;} else {prev.next = next;x.prev = null;}if (next == null) { //移除的是尾节点last = prev;} else {next.prev = prev;x.next = null;}x.item = null;size--;modCount++;return element;}

toArray()

public Object[] toArray() {//创建一个新数组 然后遍历链表,将每个元素存在数组里,返回Object[] result = new Object[size];int i = 0;for (Node<E> x = first; x != null; x = x.next)result[i++] = x.item;return result;
}
http://www.yayakq.cn/news/970005/

相关文章:

  • 宁波住房和城乡建设网站wordpress themepath
  • 建网站自己与租云服务器哪个好wordpress 框架选择
  • 网站建设怎么报价表教育类网站建设方案
  • 网站建设企业所得税大宗商品交易app
  • 网站制作文章seo优化公司
  • 网站建设 熊掌号家居设计
  • 网站 空间德州鲁企动力网站优化中心
  • 南通网站建设推广优化湛江企业网站建设流程
  • 福清做网站建立网站每项内容可以设计成什么
  • asp sqlserver做网站大连网站开发培训班
  • 的做网站公司亚马逊购物商城
  • wordpress the7 教程济南网站优化公司艾乎网
  • 网站建设先进个人自荐北京专业网站制作服务
  • 深圳常平网站建设制作公司爱情表白网站制作
  • 校园网站建设的开题报告wordpress视频广告插件
  • 门户网站开发难点产品开发项目管理
  • linux wordpress 建站教程西安网站建设网络公司熊掌号
  • html的网站案例wordpress分类目录标题使用自定义
  • 安庆网站建设专业网站建设费一般摊销几年
  • 公司网站重新备案天津电力建设公司招标网站
  • wordpress视频网站采集网站主题模板下载不了
  • 主流网站宽度vi设计要做什么
  • ie浏览器打开怎么是2345网址导航seo网站架构
  • 卖手机网站开发的必要性在那里建立公司网站
  • 南宁公司网站设计中卫网站推广软件
  • 支付网站建设费常州网页搜索排名提升
  • 响应式门户网站模板西安装修公司排名
  • 网站上怎么做浮标做平台的网站有哪些内容吗
  • 建外卖网站邢台谷歌seo
  • 关于当当网站建设方案常见制作网页的软件