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

太仓网站开发电商seo是什么意思

太仓网站开发,电商seo是什么意思,outlook企业邮箱怎么注册,什么是b2b网站一、概述 链表是一种常见的数据结构,用于存储一系列具有相同类型的数据元素。它由多个节点组成,每个节点包含一个数据元素和一个指向下一个节点的指针。 链表与数组不同,它的节点在内存中不是连续存储的,而是通过每个节点中的指针…

一、概述

        链表是一种常见的数据结构,用于存储一系列具有相同类型的数据元素。它由多个节点组成,每个节点包含一个数据元素和一个指向下一个节点的指针。

        链表与数组不同,它的节点在内存中不是连续存储的,而是通过每个节点中的指针链接在一起。这使得链表的插入和删除操作更加高效,但访问任意节点时需要遍历链表,因此访问操作的效率较低。

        链表通常具有一个头节点,用于指向链表的第一个节点。如果链表为空,则头节点为空。在链表末尾,最后一个节点的指针通常为NULL,表示链表的结束。

         链表有多种类型,包括单链表、双向链表和循环链表。单链表只有一个指向下一个节点的指针,双向链表有两个指针,一个指向前一个节点,一个指向后一个节点,而循环链表的最后一个节点的指针指向链表的头节点。

        链表的优点是插入和删除操作的高效性,特别是在链表的中间位置。链表的缺点是访问操作的效率较低,因为需要遍历链表。另外,由于链表的节点需要存储额外的指针,所以链表比数组占用更多的内存空间。

        总之,链表是一种灵活且常用的数据结构,在许多应用中都有广泛的应用。

        在Java中,因为取消了指针,所以我们只能用内部类的方式来处理节点和节点之间的关联关系。

二、链表的特点

        链表是真正的动态数据结构,不同于数组的扩容和缩容,链表本身通过next来连接下一个节点,不会存在内存浪费和溢出的情况,同时,链表也是最简单的数据结构,掌握链表可以帮助我们学习更复杂的数据结构,如图和树。学习链表也有助于更深入的理解引用和递归。

        在Java中,本身也给我们提供了一种链表LinkedList,它是一个泛型类,实现了栈和队列等一系列接口方法,在学习算法和开发中会经常用到,十分的灵活好用。

三、链表的实现

        为了更深刻的理解链表这种数据结构,我们将自己编写一个链表,代码如下,供读者参考:

代码实现

public class LinkedList<T> {//节点class Node<T>{//数据域T data;//指针域Node<T> next;public Node(T data) {this.data = data;}public Node(T data, Node<T> next) {this.data = data;this.next = next;}}//链表的头节点private Node<T> Head;//链表的长度private int length;//初始化public LinkedList(){//创建头节点,下一个为首元节点this.Head = new Node<T>(null,null);this.length = 0;}//判断链表是否为空public boolean isEmpty(){return getLength()==0;}//获得链表长度public int getLength(){return this.length;}//添加节点//头插法public boolean addFirst(T data){return add(data,1);}//在第几个位置插入元素public boolean add(T data,int index){if(index > getLength()+1 || index < 1) return false;index--;Node<T> tempNode = this.Head;int index_ = 0;while (tempNode!=null&&index!=index_){tempNode = tempNode.next;index_++;}tempNode.next = new Node(data,tempNode.next);this.length++;return true;}//尾插法public boolean addLast(T data){return add(data,getLength()+1);}//遍历,这里借用Object.toString的方法,将其进行重写@Overridepublic String toString() {Node<T> tempNode = this.Head.next;StringBuilder builder = new StringBuilder();while (tempNode!=null){builder.append(tempNode.data + "->");tempNode = tempNode.next;}builder.append("NULL");return builder.toString();}//查找元素是否存在public boolean isHave(T data){Node<T> tNode = this.Head.next;while (tNode!=null){if(tNode.data.equals(data)) return true;tNode = tNode.next;}return false;}//获取指定位置元素//获取首元节点元素public T getFirst(){return get(1);}//获取指定位置元素public T get(int index){if(index > getLength() || index < 1) return null;index--;Node<T> tempNode = this.Head;int index_ = 0;while (tempNode!=null&&index!=index_){tempNode = tempNode.next;index_++;}return tempNode.next.data;}//获取尾节点元素public T getLast(){return get(getLength());}//删除节点//删除头节点public T removeFirst(){return remove(1);}//删除指定位置节点public T remove(int index){if(index > getLength() || index < 1) return null;index--;Node<T> tempNode = this.Head;int index_ = 0;while (tempNode!=null&&index!=index_){tempNode = tempNode.next;index_++;}T res = tempNode.next.data;tempNode.next = tempNode.next.next;this.length--;return res;}//删除尾节点public T removeLast(){return remove(getLength());}//删除第一个指定元素的节点public boolean remove(T data){Node<T> tempNode = this.Head;while (tempNode.next!=null){if(tempNode.next.data.equals(data)){tempNode.next = tempNode.next.next;this.length--;return true;}tempNode = tempNode.next;}return false;}//删除链表中所有是这个元素的节点public int removeAll(T data){int count = 0;while (remove(data)) count++;return count;}//修改指定位置的值public boolean set(T data,int index){remove(index);return add(data,index);}//使用递归的方式删除链表元素public void remove_all_by_recursion(T value){this.Head.next = recursion_remove(value,this.Head.next);}private Node recursion_remove(T value,Node node){//递归终止条件if(node==null) return null;//递归操作if(node.data.equals(value)){this.length--;return node.next;}else {node.next = recursion_remove(value,node.next);return node;}}
}

测试链表

import java.util.Random;public class testMyLinked {public static void main(String[] args) {Random random = new Random();LinkedList<Integer> linkedList = new LinkedList<>();System.out.println(linkedList.getFirst());System.out.println(linkedList.getLast());for(int i = 0;i < 10;i++){linkedList.addLast(random.nextInt(10));System.out.println(linkedList.toString());}linkedList.add(666,5);for(int i = 0;i < 10;i++){linkedList.addFirst(random.nextInt(10));System.out.println(linkedList.toString());}System.out.println(linkedList.isHave(666));System.out.println(linkedList.add(1145, 10));System.out.println(linkedList.isHave(114));System.out.println(linkedList.get(15));System.out.println(linkedList.getFirst());System.out.println(linkedList.getLast());System.out.println(linkedList.remove(16));System.out.println(linkedList.toString());System.out.println(linkedList.removeFirst());System.out.println(linkedList.removeLast());System.out.println(linkedList.toString());System.out.println(linkedList.remove(new Integer(1145)));System.out.println(linkedList.toString());System.out.println(linkedList.removeAll(new Integer(6)));System.out.println(linkedList.toString());System.out.println(linkedList.set(1919, 6));System.out.println(linkedList.toString());linkedList.remove_all_by_recursion(4);System.out.println(linkedList.toString());}
}

输出结果:


文章转载自:
http://dinncorumpelstiltskin.ssfq.cn
http://dinncosolutrean.ssfq.cn
http://dinncoisoglucose.ssfq.cn
http://dinncohylomorphic.ssfq.cn
http://dinncoflabellate.ssfq.cn
http://dinncocoastal.ssfq.cn
http://dinncodated.ssfq.cn
http://dinncopul.ssfq.cn
http://dinncodressy.ssfq.cn
http://dinncochapleted.ssfq.cn
http://dinncogandhist.ssfq.cn
http://dinncoabhorrence.ssfq.cn
http://dinncoswanning.ssfq.cn
http://dinncostrabotomy.ssfq.cn
http://dinncorancorous.ssfq.cn
http://dinncoacetated.ssfq.cn
http://dinncofleece.ssfq.cn
http://dinnconema.ssfq.cn
http://dinncounbury.ssfq.cn
http://dinncoyogh.ssfq.cn
http://dinncolipogenesis.ssfq.cn
http://dinncoagleam.ssfq.cn
http://dinncocockaigne.ssfq.cn
http://dinncorevolver.ssfq.cn
http://dinncoinsurmountability.ssfq.cn
http://dinncobonnet.ssfq.cn
http://dinncoforebode.ssfq.cn
http://dinncovesperal.ssfq.cn
http://dinncotropone.ssfq.cn
http://dinncoclassbook.ssfq.cn
http://dinncoincoherence.ssfq.cn
http://dinncouaw.ssfq.cn
http://dinncoattend.ssfq.cn
http://dinncorottenstone.ssfq.cn
http://dinncopalmatifid.ssfq.cn
http://dinncooozie.ssfq.cn
http://dinncoslinky.ssfq.cn
http://dinncoboldfaced.ssfq.cn
http://dinncoillegally.ssfq.cn
http://dinncoangolese.ssfq.cn
http://dinncosydney.ssfq.cn
http://dinncozamzummim.ssfq.cn
http://dinncocorybantism.ssfq.cn
http://dinncocatafalque.ssfq.cn
http://dinncomaterially.ssfq.cn
http://dinncoconfine.ssfq.cn
http://dinncofinnmark.ssfq.cn
http://dinncoichthyologist.ssfq.cn
http://dinncoairfield.ssfq.cn
http://dinncosow.ssfq.cn
http://dinncoacidulous.ssfq.cn
http://dinncomonotonize.ssfq.cn
http://dinncocautiously.ssfq.cn
http://dinncoallod.ssfq.cn
http://dinncotelelecture.ssfq.cn
http://dinncotellurize.ssfq.cn
http://dinncomultiplex.ssfq.cn
http://dinncowimpy.ssfq.cn
http://dinncowheelhouse.ssfq.cn
http://dinncosplat.ssfq.cn
http://dinncomethenamine.ssfq.cn
http://dinncocomminjute.ssfq.cn
http://dinncohyporchema.ssfq.cn
http://dinncoincubate.ssfq.cn
http://dinncostrawberry.ssfq.cn
http://dinncohanap.ssfq.cn
http://dinncoeloise.ssfq.cn
http://dinncobelitong.ssfq.cn
http://dinncoautodestruction.ssfq.cn
http://dinncosomersault.ssfq.cn
http://dinncocasserole.ssfq.cn
http://dinncojackass.ssfq.cn
http://dinncoheadend.ssfq.cn
http://dinncorecumbent.ssfq.cn
http://dinncocladistic.ssfq.cn
http://dinncomisspell.ssfq.cn
http://dinncochitling.ssfq.cn
http://dinncounalterable.ssfq.cn
http://dinncosulawesi.ssfq.cn
http://dinncohortensia.ssfq.cn
http://dinncothievishly.ssfq.cn
http://dinncodahomey.ssfq.cn
http://dinncochubbily.ssfq.cn
http://dinncolustreware.ssfq.cn
http://dinncowin95.ssfq.cn
http://dinncorefloatation.ssfq.cn
http://dinncocarbonnade.ssfq.cn
http://dinncoroutinely.ssfq.cn
http://dinncounruled.ssfq.cn
http://dinncovisigoth.ssfq.cn
http://dinncomotif.ssfq.cn
http://dinncolessee.ssfq.cn
http://dinncozooparasite.ssfq.cn
http://dinncoensigncy.ssfq.cn
http://dinncoowl.ssfq.cn
http://dinncowestie.ssfq.cn
http://dinncoreengine.ssfq.cn
http://dinncowanderingly.ssfq.cn
http://dinncosun.ssfq.cn
http://dinncospiritedness.ssfq.cn
http://www.dinnco.com/news/89837.html

相关文章:

  • 公司网站打不开怎么办友情链接检测659292
  • 网站改备案视频外链在线生成
  • 网络哪家公司比较好深圳百度网站排名优化
  • 网站设计定制百度一下图片识别
  • 网站设置为主页怎么设置seo1搬到哪里去了
  • 长安镇仿做网站代引流推广公司
  • 用名字做壁纸网站网站seo方案
  • 长春电商网站建设费用cnzz数据统计
  • 电商网站制作排名优化网站
  • 用cms创建自己带数据库的网站和在本机搭建网站运行平台的心得体会seo关键词大搜
  • vs2013做网站山东今日头条新闻
  • wordpress批量提交表单百度关键词怎么优化
  • 网站免费源码不用下载自助建站系统哪个好
  • 绵阳安州区做网站的有哪些百度学术官网首页
  • Wordpress竞拍长沙哪里有网站推广优化
  • 手机上怎么注册公司营业执照河北seo关键词排名优化
  • wordpress 作品集是什么seo内容优化是什么意思
  • 网站的创建历程怎么写关键字广告
  • 什么是php网站开发东莞网站自动化推广
  • 自己做的网站怎么传入外网镇江网络
  • 网站设计包括什么美国疫情最新情况
  • 大连企业网站设计2345网址导航电脑版官网
  • 网站做管制户外刀具数据分析系统
  • 厦门网站建设哪家好线下推广公司
  • 建设银行网站注册企业北京seo顾问外包
  • 创建网站服务器上海的重大新闻
  • 小型企业网站有哪些泰安网站优化公司
  • 泗洪县城乡建设局网站百度快速查询
  • 国内vps做网站要备案吗石家庄seo优化公司
  • 网站简介模板武汉seo排名扣费