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

网站建站网站开发什么网站可以做投资

网站建站网站开发,什么网站可以做投资,内蒙古住房与城乡建设厅网站网址,怎样做学校网站LinkedList就传说中的双向链表了。是List 接口的链接列表实现。实现所有可选的列表操作#xff0c;并且允许所有元素#xff08;包括 null#xff09;。除了实现 List 接口外#xff0c;LinkedList 类还为在列表的开头及结尾 get、remove 和 insert 元素提供了统一的命名方… LinkedList就传说中的双向链表了。是List 接口的链接列表实现。实现所有可选的列表操作并且允许所有元素包括 null。除了实现 List 接口外LinkedList 类还为在列表的开头及结尾 get、remove 和 insert 元素提供了统一的命名方法。这些操作允许将链接列表用作堆栈、队列或双端队列。 查看LinkedList的构造函数/*** Constructs an empty list.*/public LinkedList() {header.next header.previous header; } 这里的header变量的定义如下 private transient EntryE header new EntryE(null, null, null); 表示双向循环链表的头结点。其中的Entry定义了双向链表的结构 private static class EntryE {E element;EntryE next;EntryE previous;Entry(E element, EntryE next, EntryE previous) {this.element element;this.next next;this.previous previous;} } Entry中包括数据元素、前续结点和后续结点。 构造函数即是初始化一个只包含header头结点一个元素的双向链表。 可以得出LinkedList实质上就是一个双向链表并把header作为头结点。查看LinkedList的add(E)方法public boolean add(E e) {addBefore(e, header);return true; } add(E)方法主要指向了addBefore(E, Entry)函数 private EntryE addBefore(E e, EntryE entry) {EntryE newEntry new EntryE(e, entry, entry.previous);newEntry.previous.next newEntry;newEntry.next.previous newEntry;size;modCount;return newEntry; } 这个方法中传入的第二个参数entry为header头结点表示把元素插入到header头结点之前。然后后两句分别表示设置前续结点的后续结点和后续结点的前续结点。以便连接成双向链表。 可以得出LinkedList的add(E)方法把新结点插入到header头结点之前即列表的结尾。查看LinkedList的set(int, E)方法/*** Replaces the element at the specified position in this list with the* specified element.** param index index of the element to replace* param element element to be stored at the specified position* return the element previously at the specified position* throws IndexOutOfBoundsException {inheritDoc}*/public E set(int index, E element) {EntryE e entry(index);E oldVal e.element;e.element element;return oldVal; } 这个函数主要是设置某个索引位置的结点。首先调用了entry(int)方法 /*** Returns the indexed entry.*/private EntryE entry(int index) {if (index 0 || index size)throw new IndexOutOfBoundsException(Index: index, Size: size);EntryE e header;if (index (size 1)) {for (int i 0; i index; i)e e.next;} else {for (int i size; i index; i--)e e.previous;}return e; } 这里首先判断需要设置的位置是否越界如果越界则抛出异常。然后通过循环找到需要替换的结点。 接下来回到set(int ,E)函数把旧的结点替换成新的结点并返回旧的结点。 可以得出set(int ,E)方法需要循环遍历链表时间开销比较大。查看LinkedList的push(E)方法/*** Pushes an element onto the stack represented by this list. In other* words, inserts the element at the front of this list.** pThis method is equivalent to {link #addFirst}.** param e the element to push* since 1.6*/public void push(E e) {addFirst(e); } push(E)方法主要调用了addFirst(E)方法 /*** Inserts the specified element at the beginning of this list.** param e the element to add*/public void addFirst(E e) {addBefore(e, header.next); } 这里继续调用addBefore(E, Entity)表示把新节点插入到header头结点之后。 可以得出push(E)方法主要是把新节点插入到header头结点之后。查看LinkedList的pop()方法/*** Pops an element from the stack represented by this list. In other* words, removes and returns the first element of this list.** pThis method is equivalent to {link #removeFirst()}.** return the element at the front of this list (which is the top* of the stack represented by this list)* throws NoSuchElementException if this list is empty* since 1.6*/public E pop() {return removeFirst(); } 这里继续调用了removeFirst()方法 /*** Removes and returns the first element from this list.** return the first element from this list* throws NoSuchElementException if this list is empty*/public E removeFirst() {return remove(header.next); } 这里继续调用remove(EntryE)方法 /*** Retrieves and removes the head (first element) of this list.** return the head of this list* throws NoSuchElementException if this list is empty* since 1.5*/private E remove(EntryE e) {if (e header)throw new NoSuchElementException();E result e.element;e.previous.next e.next;e.next.previous e.previous;e.next e.previous null;e.element null;size--;modCount;return result; } 在调用remove(EntryE)方法时传入了header的下一个结点。如果传入的下一个结点是header的话表示此事链表中只有一个结点header此时抛出异常。如果找到则删除该节点注意这里双向链表删除结点时的步骤并返回被删除的结点。 可以得出pop()方法删除的是header头结点之后的结点并返回被删除的结点。★ LinkedList实质上就是一个双向链表并把header作为头结点。 ★ LinkedList的add(E)方法把新结点插入到header头结点之前。 ★ set(int ,E)方法需要循环遍历链表时间开销比较大。 ★ push(E)方法主要是把新节点插入到header结点之前 ★ pop()方法删除的是header头结点之后的结点并返回被删除的结点。
http://wiki.neutronadmin.com/news/75797/

相关文章:

  • 滑县网站建设服务常用搜索网站
  • 甘露园网站建设wordpress添加电台
  • 专题探索网站开发模式特点外贸seo搜索优化
  • 几种语言的网站如何做在线制作图片旋转动态
  • dw免费网站模板下载做T恤卖网站
  • 网站推广方法主要有哪几种时代创信网站设计 北京
  • 网站 功能呢html5电影网站模板
  • 互联网招聘网站排行营销网站建设服务
  • 为什么网站上传照片传不上去网站商城建设公司
  • 布谷 海南网站建设网站 宣传册
  • 品牌营销策划网站做广告推广哪个平台好
  • 制作制作网站建设的wordpress 分类图像描述
  • dz网站如何搬家建筑人才招聘哪个网站最好
  • 网站设计的目标是什么网站文章伪原创如何做
  • 免费建站赚钱wordpress整站打包
  • 网站注册域名查询网站做的漂亮的企业
  • 网站打不开是怎么回事手机购物网站模板下载
  • 银川做网站推广创业网站怎么做
  • 东莞制作公司网站会展网站代码源码
  • 美妆网站建设规划企业网络部署方案
  • 长春网站建设哪家好网站排名优化学习
  • 电子商务网站建设参考文献2018无锡网站建设服务
  • tklink的登录做网站为什么在百度搜不到我的网站
  • 招聘设计师去哪个网站苏州调查公司怎么收费
  • 泉州手机网站建设公司wordpress提示框美化
  • 北京通网站建设网络设计参考文献
  • 网站查询备案信息长沙seo代理
  • 网站建设合同要不要交印花税wordpress 图片延迟
  • 免费建设游戏对战平台网站开发一个网站的成本
  • 服务器512m内存做网站南京制作企业网站