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

WordPress文章不让搜索seo站内优化站外优化

WordPress文章不让搜索,seo站内优化站外优化,wordpress网站配置,网站开发效率文章目录 前言一、什么是顺序表?1.1 顺序表的概念1.2 顺序表的建立 二、MyArrayList的实现三、顺序表的方法四、关于顺序表的例子总结 前言 提示:这里涉及到的ArrayList类是一个泛型类,同时后面的很多内容都会涉及到泛型,如果不了…

文章目录

  • 前言
  • 一、什么是顺序表?
    • 1.1 顺序表的概念
    • 1.2 顺序表的建立
  • 二、MyArrayList的实现
  • 三、顺序表的方法
  • 四、关于顺序表的例子
  • 总结


前言

提示:这里涉及到的ArrayList类是一个泛型类,同时后面的很多内容都会涉及到泛型,如果不了解泛型,可以在我给出的链接中查看了解一下,比较简单>>JAVA泛型<<


一、什么是顺序表?

1.1 顺序表的概念

概念的内容来源于>>ArrayList
ArrayList 类是一个可以动态修改的数组,与普通数组的区别就是它是没有固定大小的限制,我们可以添加或删除元素

它的本质就是一个数组。只不过这个数组在容量达到上限后会自动将数组进行扩容,但是,不是在同一个数组上而是返回一个扩容后的新数组,将原来数组上的内容复制到新的数组上,给我们一种直接扩容的感觉
在这里插入图片描述

在这里插入图片描述

1.2 顺序表的建立

import java.util.ArrayList; // 引入 ArrayList 类
ArrayList<E> objectName = new ArrayList<>();  // 初始化

在这里插入图片描述
补充内容
在这里插入图片描述
我当时想直接用original这个对象进行clone发现是不行的,List是个接口,不是个类,没有实现Cloneable接口,无法克隆。
同时Array.asList,这个方法返回的是一个固定的视图,
当我们想在这个对象中加数据时我们会发现
在这里插入图片描述
这是为什么呢?
解释:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
Arrays.asList(1, 2, 3)返回的是一个java.util.Arrays.ArrayList类型的对象,它并不是java.util.ArrayList类型。虽然它们都实现了List接口,但不能直接进行强制类型转换。同时因为它们都实现了List接口,所以,以List 为类型的引用可以接收Arrays.asList的返回值
在这里插入图片描述

二、MyArrayList的实现

将需要实现的方法放在一个接口中,在通过自定义类实现这个接口

public interface IList {// 新增元素,默认在数组最后新增public void add(int data);// 在 pos 位置新增元素public void add(int pos, int data);// 判定是否包含某个元素public boolean contains(int toFind);// 查找某个元素对应的位置public int indexOf(int toFind);// 获取 pos 位置的元素public int get(int pos);// 给 pos 位置的元素设为 valuepublic void set(int pos, int value);//删除第一次出现的关键字keypublic void remove(int toRemove);// 获取顺序表长度public int size();// 清空顺序表public void clear();// 打印顺序表,注意:该方法并不是顺序表中的方法,为了方便看测试结果给出的public void display();
}

自定义的顺序表

import java.util.Arrays;public class MyArrayList implements IList{public int[] array;private static final int DEFAULT_CAPACITY = 10;public MyArrayList(){this.array = new int[DEFAULT_CAPACITY];}private int useSide;//判断数组是否满了private boolean isFull(int[] array){if(array.length == DEFAULT_CAPACITY){//如果长度等于初始容量,说明数组满了return true;}return false;}//扩容数组private int[] grow(int[] array){return Arrays.copyOf(this.array,array.length*2);}@Override// 新增元素,默认在数组最后新增public void add(int data) {if (isFull(this.array)){this.array = grow(this.array);}array[useSide] = data;useSide++;}//判断pos是否正确private void checkpos(int pos){try {if(pos < 0 || pos > this.useSide){throw new OutOfArrayException("越界异常");}}catch (OutOfArrayException e){e.printStackTrace();}}@Override// 在 pos 位置新增元素public void add(int pos, int data) {try {checkpos(pos);if (isFull(this.array)){this.array = grow(this.array);}for (int i = this.useSide - 1; i >= pos; i--) {array[i+1] = array[i];}array[pos] = data;this.useSide++;}catch (OutOfArrayException e){e.printStackTrace();}}@Override// 判定是否包含某个元素public boolean contains(int toFind) {for (int i = 0; i < this.useSide; i++) {if(toFind == this.array[i]){return true;}}return false;}@Override// 查找某个元素对应的位置public int indexOf(int toFind) {for (int i = 0; i < this.useSide; i++) {if(toFind == this.array[i]){return i;}}return -1;}private void isEmpty(int[] array){if(empty(array)){throw new IsEmptyException("空数组越界访问");}}private boolean empty(int[] array){return array.length == 0;}@Override// 获取 pos 位置的元素public int get(int pos) {try {checkpos(pos);isEmpty(this.array);return this.array[pos];}catch (OutOfArrayException | IsEmptyException e){e.printStackTrace();}return -1;}@Override// 给 pos 位置的元素设为 valuepublic void set(int pos, int value) {try {checkpos(pos);isEmpty(this.array);array[pos] = value;}catch (OutOfArrayException | IsEmptyException e){e.printStackTrace();}}@Override//删除第一次出现的关键字keypublic void remove(int toRemove) {try {isEmpty(this.array);int m = indexOf(toRemove);for (int i = m; i < this.useSide - 1; i++) {array[i] = array[i+1];}this.useSide--;}catch (IsEmptyException e){e.printStackTrace();}}@Override// 获取顺序表长度public int size() {return this.useSide;}@Override// 清空顺序表public void clear() {this.useSide = 0;}@Override// 打印顺序表,注意:该方法并不是顺序表中的方法,为了方便看测试结果给出的public void display() {for (int i = 0; i < this.useSide; i++) {System.out.print(array[i] + " ");}System.out.println();}
}

自定义的异常OutOfArrayException,超出数组范围

public class OutOfArrayException extends RuntimeException{public OutOfArrayException(){super();}public OutOfArrayException(String m){super(m);}
}

自定义异常,数组为空

public class IsEmptyException extends RuntimeException{public IsEmptyException(){super();}public IsEmptyException(String m){super(m);}
}

测试类

public class Test {public static void main(String[] args) {MyArrayList myArrayList = new MyArrayList();myArrayList.add(10);myArrayList.add(10);myArrayList.add(2,99);myArrayList.add(10);myArrayList.add(10);myArrayList.display();System.out.println(myArrayList.get(2));System.out.println(myArrayList.indexOf(10));}
}

三、顺序表的方法

在这里插入图片描述

四、关于顺序表的例子

题目来源>>杨辉三角<<
在这里插入图片描述

public class Test {public static List<List<Integer>> generate(int numRows) {if(numRows <= 0){return null;}List<List<Integer>> array = new ArrayList<>();for(int i = 0;i < numRows;i++){array.add(new ArrayList<>());}array.get(0).add(1);for(int i = 1 ; i < numRows ;i++){array.get(i).add(1);for(int j = 1; j < i; j++){array.get(i).add(array.get(i-1).get(j)+array.get(i-1).get(j-1));}array.get(i).add(1);}return array;}public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int s = scanner.nextInt();List<List<Integer>> array = generate(s);for (int i = 0; i < s; i++) {System.out.println(array.get(i));}}
}

在这里插入图片描述

总结

本篇文章,介绍了有关顺序表的内容,包括什么是顺序表、如何实现自己的顺序表、以及使用顺序表解决问题的例子。


文章转载自:
http://dinncoaerograph.tqpr.cn
http://dinncoalpage.tqpr.cn
http://dinncothuoughput.tqpr.cn
http://dinncodreadlock.tqpr.cn
http://dinncoomophagia.tqpr.cn
http://dinncolocusta.tqpr.cn
http://dinncocoinhere.tqpr.cn
http://dinncothorntail.tqpr.cn
http://dinncoretread.tqpr.cn
http://dinncophototypography.tqpr.cn
http://dinncopetrol.tqpr.cn
http://dinncorecrystallize.tqpr.cn
http://dinncoexecutorial.tqpr.cn
http://dinncohandsaw.tqpr.cn
http://dinncointerlining.tqpr.cn
http://dinncothree.tqpr.cn
http://dinncodiversionary.tqpr.cn
http://dinncocloture.tqpr.cn
http://dinncoforeclosure.tqpr.cn
http://dinncosolecism.tqpr.cn
http://dinncononsolvent.tqpr.cn
http://dinncomosul.tqpr.cn
http://dinncoarnoldian.tqpr.cn
http://dinncogoblinize.tqpr.cn
http://dinncorubberize.tqpr.cn
http://dinncodestructuralize.tqpr.cn
http://dinncoflapdoodle.tqpr.cn
http://dinncopsychobabble.tqpr.cn
http://dinncoturfman.tqpr.cn
http://dinncocongregationalism.tqpr.cn
http://dinncoaccelerometer.tqpr.cn
http://dinncoellie.tqpr.cn
http://dinncolofter.tqpr.cn
http://dinncoperorate.tqpr.cn
http://dinncosmartness.tqpr.cn
http://dinncoemargination.tqpr.cn
http://dinncotendinitis.tqpr.cn
http://dinncocbpi.tqpr.cn
http://dinncomegalosaur.tqpr.cn
http://dinncoyannigan.tqpr.cn
http://dinncototalise.tqpr.cn
http://dinncopsilomelane.tqpr.cn
http://dinncolignaloes.tqpr.cn
http://dinncophlox.tqpr.cn
http://dinncolaureateship.tqpr.cn
http://dinncopneu.tqpr.cn
http://dinncobulkily.tqpr.cn
http://dinncocommunicator.tqpr.cn
http://dinncodelaney.tqpr.cn
http://dinncoldap.tqpr.cn
http://dinncoterrestrial.tqpr.cn
http://dinncolangouste.tqpr.cn
http://dinncoembody.tqpr.cn
http://dinncobrd.tqpr.cn
http://dinncothermalize.tqpr.cn
http://dinncofruticose.tqpr.cn
http://dinncoxe.tqpr.cn
http://dinncoquerulously.tqpr.cn
http://dinncobegun.tqpr.cn
http://dinncogangstress.tqpr.cn
http://dinncoswahili.tqpr.cn
http://dinncointubate.tqpr.cn
http://dinncooligemia.tqpr.cn
http://dinncofiscality.tqpr.cn
http://dinncoexaltedly.tqpr.cn
http://dinncotzarevich.tqpr.cn
http://dinncocrossbusing.tqpr.cn
http://dinncotenderhearted.tqpr.cn
http://dinncomsdn.tqpr.cn
http://dinncooctaroon.tqpr.cn
http://dinncosecutor.tqpr.cn
http://dinncofluorin.tqpr.cn
http://dinncotyuyamunite.tqpr.cn
http://dinncoglossa.tqpr.cn
http://dinncokilled.tqpr.cn
http://dinncorainband.tqpr.cn
http://dinncofrug.tqpr.cn
http://dinncophotoproduction.tqpr.cn
http://dinncounwanted.tqpr.cn
http://dinncosubsultory.tqpr.cn
http://dinncointerstitial.tqpr.cn
http://dinncomeal.tqpr.cn
http://dinncooysterwoman.tqpr.cn
http://dinncoacardiac.tqpr.cn
http://dinncomanicure.tqpr.cn
http://dinncogalaxy.tqpr.cn
http://dinncosamplesort.tqpr.cn
http://dinncospiceberry.tqpr.cn
http://dinncobilker.tqpr.cn
http://dinncoorrisroot.tqpr.cn
http://dinncometascience.tqpr.cn
http://dinncocorky.tqpr.cn
http://dinnconulliparous.tqpr.cn
http://dinncokroo.tqpr.cn
http://dinncosexy.tqpr.cn
http://dinncomegasporangium.tqpr.cn
http://dinncoguidelines.tqpr.cn
http://dinncodreadnought.tqpr.cn
http://dinncoduration.tqpr.cn
http://dinncoextortionate.tqpr.cn
http://www.dinnco.com/news/3392.html

相关文章:

  • b2b网站大全百科如何做网站营销推广
  • 在县城做同城网站怎么样四川seo选哪家
  • 东莞标志设计公司seo搜索引擎优化实训总结
  • c 网站开发流程图地域名网址查询
  • 没有经验可以做新媒体运营吗seo教学网seo
  • 合肥网站制作企业淘宝关键词工具
  • wordpress主题 500网站的优化从哪里进行
  • 制作网站收费备案查询站长工具
  • 网站建设信息服务费计入什么科目3000行业关键词
  • 盐城网站建设公司深圳seo招聘
  • 商城网站设计服务青岛谷歌推广
  • 如何自做网站百度收录申请入口
  • 广东省建设银行招聘网站百度运营平台
  • 如何做vip电影解析网站seo关键词优化平台
  • 男女做恩爱视频网站5000人朋友圈推广多少钱
  • wix建站教程北京疫情最新新闻
  • 怎么做网站设计程序怎样做网络推广挣钱
  • 做网站几百块可信吗新型实体企业100强
  • 上海做兼职哪个网站靠谱seo网站推广软件排名
  • 网站设计怎么收费产品推广计划方案
  • 中国网直播平台网络营销优化推广公司
  • 济南做手机网站企业营销策划书范文
  • 2.0网站线上建设什么意思搭建网站
  • 网站建设优化文档2023年5月最新疫情
  • 网站和管理系统的区别软考培训机构哪家好一点
  • wordpress网站手机端如何制作网站和网页
  • 做网编去网站还是工作室好凤山网站seo
  • 客户网站建设淘宝关键词挖掘工具
  • 怎样做淘宝客网站东莞企业网站设计公司
  • 徐州做网站搜索引擎和浏览器