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

百度一下你就知道天津seo优化排名

百度一下你就知道,天津seo优化排名,昆山市网站建设,旅游门户网站建设方案💕"世事犹如书籍,一页页被翻过去。人要向前看,少翻历史旧账。"💕 作者:Mylvzi 文章主要内容:数据结构之顺序表的模拟实现 /*** Created with IntelliJ IDEA.* Description:* User: 绿字* Date:…

 💕"世事犹如书籍,一页页被翻过去。人要向前看,少翻历史旧账。"💕

作者:Mylvzi 

 文章主要内容:数据结构之顺序表的模拟实现 

 

/*** Created with IntelliJ IDEA.* Description:* User: 绿字* Date: 2023-10-12* Time: 8:53*/
import java.util.*;
/*** 顺序表详解*/
public class MyArrayList {private int[] elem;// 存放数据的数组private int usedSize;// 有效数据个数public static final int DEFAULT_SIZE = 10;// 初始化顺序表public MyArrayList() {this.elem = new int[DEFAULT_SIZE];}public MyArrayList(int ininCapacity) {// 自定义数组的大小this.elem = new int[ininCapacity];}// 打印顺序表public void display() {for (int i = 0; i <this.usedSize ; i++) {System.out.print(this.elem[i] +" ");}}// 添加数据  默认是在末尾添加public void add(int data) {// 满了要扩容if(isFull()) {this.elem = Arrays.copyOf(this.elem,2*this.elem.length);}this.elem[usedSize] = data;this.usedSize++;}// 判断是否已满public boolean isFull() {if(this.usedSize == this.elem.length) {return true;}return false;}// 在 pos 位置新增元素public void add(int pos, int data) {// pos位置要合法if(pos<0 || pos>this.usedSize) {throw new RuntimeException(pos+"位置不合法");}if(isFull()) {this.elem = Arrays.copyOf(this.elem,2*this.elem.length);}for (int i = this.usedSize-1; i >=pos ; i--) {this.elem[i+1] = this.elem[i];}this.elem[pos] = data;this.usedSize++;}// 判定是否包含某个元素public boolean contains(int toFind) {for (int i = 0; i <this.usedSize ; i++) {if(this.elem[i] == toFind) {return true;}}System.out.println("数组不包含该元素");return false;}// 查找某个元素对应的位置public int indexOf(int toFind) {for (int i = 0; i <this.usedSize ; i++) {if(this.elem[i] == toFind) {return i;}}System.out.println("数组不包含该元素");return -1;}// 检查pos位置是否合法private void checkPosLegal(int pos) {if(pos<0 || pos>=this.usedSize) {throw new posOutOfBoundException(pos+" 位置不合法");}}// 获取 pos 位置的元素public int get(int pos) {checkPosLegal(pos);return this.elem[pos];}// 给 pos 位置的元素设为 value  pos位置必须含有元素public void set(int pos, int value) {checkPosLegal(pos);this.elem[pos] = value;}//删除第一次出现的关键字keypublic void remove(int toRemove) {int index = indexOf(toRemove);for (int i = index; i <this.usedSize-1 ; i++) {this.elem[i] = this.elem[i+1];}this.usedSize--;}// 获取顺序表长度public int size() {return this.usedSize;}// 清空顺序表public void clear() {// 如果是引用类型所有的引用都要置空
//        for (int i = 0; i <this.usedSize; i++) {
//            this.elem[i] = null;
//        }this.usedSize = 0;}
}
/*** Created with IntelliJ IDEA.* Description:* User: 绿字* Date: 2023-10-12* Time: 10:49*/
public class posOutOfBoundException extends RuntimeException{public posOutOfBoundException() {}public posOutOfBoundException(String message) {super(message);}
}
/*** Created with IntelliJ IDEA.* Description:* User: 绿字* Date: 2023-10-12* Time: 9:02*/
public class Test1 {public static void main(String[] args) {MyArrayList myArrayList = new MyArrayList(5);myArrayList.add(1);myArrayList.add(2);myArrayList.add(3);myArrayList.add(4);
/*        System.out.println(myArrayList.size());myArrayList.remove(1);System.out.println(myArrayList.size());*/
//        myArrayList.add(100,99);
/*        myArrayList.set(0,999);myArrayList.remove(999);myArrayList.remove(2);myArrayList.remove(3);myArrayList.remove(4);myArrayList.remove(5);*//*        System.out.println(myArrayList.get(0));System.out.println(myArrayList.get(-1));System.out.println(myArrayList.get(999));*/
//        System.out.println(myArrayList.contains(2));
//        System.out.println(myArrayList.indexOf(2));
//
/*        myArrayList.add(0,999);myArrayList.add(0,999);myArrayList.add(0,999);myArrayList.add(0,999);myArrayList.add(0,999);*/
myArrayList.clear();myArrayList.display();}
}

http://www.rdtb.cn/news/966.html

相关文章:

  • 企业黄页网站源码品牌宣传策划方案
  • 建站公司网站建设百青藤广告联盟
  • 易龙天做的网站怎么样网站应该如何推广
  • 政务网站建设交流发言现在的网络推广怎么做
  • 查询备案网站腾讯nba新闻
  • 网站seo报表seo全网推广营销软件
  • 企业网站建设方案论文长春网站关键词排名
  • 从留言板开始做网站建站宝盒
  • 免费tickle网站it行业培训机构哪个好
  • 网站建设jiqb站推广网站入口
  • 域名除了做网站还能做什么广州百度推广代理公司
  • 做网站用java关键词爱站网关键词挖掘工具
  • 网站更新怎么做seo企业推广案例
  • 简单的网站建设网络营销的基本功能
  • 网站开发中的paml网站设计制作哪家好
  • 推荐软件分类seo服务公司上海
  • 网站网页设计原则t和p在一起怎么做网站
  • 深圳商城网站开发优秀网站设计
  • 个人可以做商城网站百度推广找谁做靠谱
  • 网站 目录结构百度推广电话号码
  • jsp网站开发论文做市场推广应该掌握什么技巧
  • ui设计需要学什么软件seo是什么意思呢
  • 自由型网站永久免费的电销外呼系统
  • 男生女生做羞羞事的网站网站收录怎么弄
  • 北京西站附近景点网络推广优化平台
  • 常见的域名注册网站企业网站推广效果指标分析
  • 潍坊网站建设公司哪家好公司官网优化方案
  • 大连网站哪家做的好网络广告案例以及分析
  • 免费建个人手机网站搜索引擎优化方法
  • 中色冶金建设有限公司网站泉州百度seo公司