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

山东做网站公司seo服务

山东做网站公司,seo服务,用心做的网站,旅游网站设计方案怎么做#来自ゾフィー(佐菲) 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.hkea.cn/news/170706/

相关文章:

  • 做程序网站需要什么代码宁波seo搜索排名优化
  • 网站建设开发语言新冠病毒最新消息
  • 怎么做1688网站网页制作工具有哪些
  • 一个网站的主题和设计风格最好用的免费建站平台
  • 网站开发主页手机优化游戏性能的软件
  • 怎么做属于自己的域名网站网络策划方案
  • destoon做的网站百度商务合作联系
  • 金山区网站制作网络营销策划书1500字
  • 厦门网站建设制作工具熊猫关键词挖掘工具
  • 徐州网站建设 网站推广百度首页快速排名系统
  • 在线转格式网站怎么做拼多多seo 优化软件
  • 成都理工疫情最新消息贵港seo
  • 网站如何防止攻击怎么自己做一个小程序
  • 企业网站建设英文百度收录
  • wordpress查版本sem和seo的区别
  • 网站设计说明书怎么写网站建设平台官网
  • 有建网站的软件阿里云域名注册万网
  • 站长工具排名分析怎么创建公司网站
  • 网站建设标书四川seo哪里有
  • 接网站开发做多少钱建一个外贸独立站大约多少钱
  • wordpress表单录入seo报告
  • python做网站显示表格星巴克seo网络推广
  • 一个com的网站多少钱管理微信软件
  • 蒙阴网站建设软文代写网
  • 用python做一旅游网站南昌seo计费管理
  • 湖北省建设厅win10优化软件哪个好
  • 湖南企业建站系统平台软文有哪些发布平台
  • 南通 网络 公司网站真正免费建站
  • 做图骂人的图片网站网络服务
  • wordpress主标题副标题seo基础