网站建设 微信营销宣传广告牌图片

web/2025/10/6 14:48:15/文章来源:
网站建设 微信营销,宣传广告牌图片,网站建设价格标签,企业管理系统项目简介怎么写好转载自 java.util.Stack类简介 Stack是一个后进先出#xff08;last in first out#xff0c;LIFO#xff09;的堆栈#xff0c;在Vector类的基础上扩展5个方法而来 Deque#xff08;双端队列#xff09;比起Stack具有更好的完整性和一致性#xff0c;应该被优先使用…转载自  java.util.Stack类简介 Stack是一个后进先出last in first outLIFO的堆栈在Vector类的基础上扩展5个方法而来 Deque双端队列比起Stack具有更好的完整性和一致性应该被优先使用 E push(E item)             把项压入堆栈顶部。    E pop()             移除堆栈顶部的对象并作为此函数的值返回该对象。    E peek()             查看堆栈顶部的对象但不从堆栈中移除它。    boolean empty()             测试堆栈是否为空。     int search(Object o)             返回对象在堆栈中的位置以 1 为基数。 Stack本身通过扩展Vector而来而Vector本身是一个可增长的对象数组 a growable array of objects那么这个数组的哪里作为Stack的栈顶哪里作为Stack的栈底 答案只能从源代码中寻找jdk1.6 public class StackE extends VectorE { /** * Creates an empty Stack. */ public Stack() { } /** * Pushes an item onto the top of this stack. This has exactly * the same effect as: * blockquotepre * addElement(item)/pre/blockquote * * param item the item to be pushed onto this stack. * return the codeitem/code argument. * see java.util.Vector#addElement */ public E push(E item) { addElement(item); return item; } /** * Removes the object at the top of this stack and returns that * object as the value of this function. * * return The object at the top of this stack (the last item * of the ttVector/tt object). * exception EmptyStackException if this stack is empty. */ public synchronized E pop() { E obj; int len size(); obj peek(); removeElementAt(len - 1); return obj; } /** * Looks at the object at the top of this stack without removing it * from the stack. * * return the object at the top of this stack (the last item * of the ttVector/tt object). * exception EmptyStackException if this stack is empty. */ public synchronized E peek() { int len size(); if (len 0) throw new EmptyStackException(); return elementAt(len - 1); } /** * Tests if this stack is empty. * * return codetrue/code if and only if this stack contains * no items; codefalse/code otherwise. */ public boolean empty() { return size() 0; } /** * Returns the 1-based position where an object is on this stack. * If the object tto/tt occurs as an item in this stack, this * method returns the distance from the top of the stack of the * occurrence nearest the top of the stack; the topmost item on the * stack is considered to be at distance tt1/tt. The ttequals/tt * method is used to compare tto/tt to the * items in this stack. * * param o the desired object. * return the 1-based position from the top of the stack where * the object is located; the return value code-1/code * indicates that the object is not on the stack. */ public synchronized int search(Object o) { int i lastIndexOf(o); if (i 0) { return size() - i; } return -1; } /** use serialVersionUID from JDK 1.0.2 for interoperability */ private static final long serialVersionUID 1224463164541339165L; } 通过peek()方法注释The object at the top of this stack (the last item of the Vector object可以发现数组Vector的最后一位即为Stack的栈顶 pop、peek以及search方法本身进行了同步 push方法调用了父类的addElement方法 empty方法调用了父类的size方法 Vector类为线程安全类 综上Stack类为线程安全类(多个方法调用而产生的数据不一致问题属于原子性问题的范畴) public class Test { public static void main(String[] args) { StackString s new StackString(); System.out.println(------isEmpty); System.out.println(s.isEmpty()); System.out.println(------push); s.push(1); s.push(2); s.push(3); Test.it(s); System.out.println(------pop); String str s.pop(); System.out.println(str); Test.it(s); System.out.println(------peek); str s.peek(); System.out.println(str); Test.it(s); System.out.println(------search); int i s.search(2); System.out.println(i); i s.search(1); System.out.println(i); i s.search(none); System.out.println(i); } public static void it(StackString s){ System.out.print(iterator:); IteratorString it s.iterator(); while(it.hasNext()){ System.out.print(it.next();); } System.out.print(\n); } } 结果 ------isEmpty   true             ------push   iterator:1;2;3;     ------pop   3       --栈顶是数组最后一个   iterator:1;2;   ------peek   2       --pop取后删掉peek只取不删   iterator:1;2;   ------search       1       --以1为基数即栈顶为1   2       --和栈顶见的距离为2-11   -1      --不存在于栈中   Stack并不要求其中保存数据的唯一性当Stack中有多个相同的item时调用search方法只返回与查找对象equal并且离栈顶最近的item与栈顶间距离见源码中search方法说明

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/87966.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

浙江省工程建设管理质量协会网站怎么推广自己的qq群

2 疑问 2.1 这里的“只有当线程池是无界的或者可以拒绝任务时,该队列才有实际价值”,为什么这么说 SynchronousQueue是一种特殊的队列,它不保留任务,而是直接将任务移交给工作线程。这种队列适合于执行大量生命周期非常短的异步…

医院管理系统网站模板保定建设局网站

末端方法 末端方法是对流的最终操作。当对某个 Stream 执行末端方法后,该流将会被"消耗"
且不再可用。换句话说就是末端方法一旦调用后就会关闭流,再不能对流进行操作,否则会抛出异常。 方法功能forEach(Consumer action)遍历流…

河南平台网站建设制作网络推广营销网

queue是队列,特点是先进先出,后进后出,你可以理解为数据结构里的队列模型,他只允许你访问 queue<T> 容器适配器的第一个和最后一个元素。只能在容器的末尾添加新元素,只能从头部移除元素。许多程序都使用了 queue 容器。queue 容器可以用来表示超市的结账队列或服务…

wordpress建站工具包自媒体多平台发布工具

7-15 BCD解密 BCD数是用一个字节来表达两位十进制的数&#xff0c;每四个比特表示一位。所以如果一个BCD数的十六进制是0x12&#xff0c;它表达的就是十进制的12。但是小明没学过BCD&#xff0c;把所有的BCD数都当作二进制数转换成十进制输出了。于是BCD的0x12被输出成了十进制…

学网站建设多少学费免费wordpress企业主题

本次练习的任务是使用逻辑归回和神经网络进行识别手写数字&#xff08;form 0 to 9, 自动手写数字问题已经应用非常广泛&#xff0c;比如邮编识别。 使用逻辑回归进行多分类分类 练习2 中的logistic 回归实现了二分类分类问题&#xff0c;现在将进行多分类&#xff0c;one vs…

网站建设前景怎么样公司建立网站的必要性

多维时序 | MATLAB实现WOA-CNN-BiGRU-Attention多变量时间序列预测&#xff08;SE注意力机制&#xff09; 目录 多维时序 | MATLAB实现WOA-CNN-BiGRU-Attention多变量时间序列预测&#xff08;SE注意力机制&#xff09;预测效果基本描述模型描述程序设计参考资料 预测效果 基本…

建个电子商务网站多少钱网站建设程序制作

open函数 要点&#xff1a; int open(const char *pathname, int flags); perror函数 close函数 控制台输入&#xff1a; man 2 open2 表示第二章&#xff08;Linux系统IO函数位于第二章&#xff09;&#xff0c;第三章是标准C库的一些函数部分输出&#xff1a; 1、open函数返…

宁津网站开发网站开发需要的技术人员有什么软件

前言&#xff1a;在Quartz.Net项目发布第一版Quartz.Net分布式任务管理平台后&#xff0c;有挺多园友去下载使用&#xff0c;我们通过QQ去探讨&#xff0c;其中项目中还是存在一定的不完善。所以有了现在这个版本。这个版本的编写完成其实有段时间了一直没有放上去。现在已经同…

外国茶网站建设如何做一间公司的网站

在Python中&#xff0c;可以使用Pandas库中的Series.to_json()方法将Series对象转换为JSON格式的字符串。以下是一个简单的例子&#xff1a; import pandas as pd# 创建一个Pandas Seriess pd.Series({a: 1, b: 2, c: 3})# 转换为JSON字符串json_str s.to_json(orientrecords…

建网站需要编程吗地方网站类型

在centos服务器中配置好vsftp后&#xff0c;开了root用户上传权限&#xff0c;也关了系统的防火墙&#xff0c;但ftp连接的时候依然还会出现 "550 Create directory operation failed." 错误&#xff0c;如何解决呢&#xff1f; 解决&#xff1a; 1、查看 SELinux 的…

网站代理协议汕头网页怎么制作

SpringBoot教程&#xff08;十五&#xff09; | SpringBoot集成RabbitMq&#xff08;消息丢失、消息重复、消息顺序、消息顺序&#xff09; RabbitMQ常见问题解决方案问题一&#xff1a;消息丢失的解决方案&#xff08;1&#xff09;生成者丢失消息丢失的情景解决方案1&#xf…

网站建设与管理 规划书投诉举报网站 建设方案

目录 uni-app介绍 uni-app开发工具HBuilderX 创建项目前提条件 uni-app项目结构 配置mumu模拟器 uni-app生命周期 1.应用生命周期 小程序规范 2.页面生命周期-小程序规范 3.组件生命周期 vue规范 uni-app登录按钮方法 uni-app发布安卓app uni-app介绍 uni-app 是一个…

仿99健康网网站源码为什么有网网站打不开怎么回事啊

一、选择数据库 在 MySQL 中&#xff0c;要选择&#xff08;或称为切换到&#xff09;一个数据库&#xff0c;可以使用 SQL 命令 USE。 USE database_name; database_name 是你要切换到的数据库的名称。 例如&#xff0c;要切换到名为 my_database 的数据库&#xff0c;可以…

长沙哪家网站公司wordpress 导航栏搜索

1.新建&#xff08;New&#xff09;: 线程对象已创建&#xff0c;但还没有调用 start() 方法。 2.可运行&#xff08;Runnable&#xff09;: 线程已启动&#xff0c;处于就绪状态&#xff0c;等待 JVM 的线程调度器分配CPU时间。 3.阻塞&#xff08;Blocked&#xff09;: 线程…

申请阿里巴巴网站首页wordpress pdf 加密

一、前言 对于大型企业而言&#xff0c;数据已经成为基本的生产资料&#xff0c;但是有很多公司还是值关心上层应用&#xff0c;而忽略了数据的治理&#xff0c;从而并不能很好的发挥公司的数据资产效益。比如博主自己是做后端的&#xff0c;主要是做应用层&#xff0c;也就是…

使用腾讯云建设网站教程wordpress的安全错误

模拟固定吞吐量的定时器。它可以控制测试计划中各个请求之间的时间间隔&#xff0c;以达到预期的吞吐量。 参数包括&#xff1a; Target Throughput&#xff1a;目标吞吐量&#xff08;每分钟请求数&#xff09;Calculate Throughput based on&#xff1a;吞吐量计算基准&…

google推广妙招百度怎么优化关键词排名

在使用 BeautifulSoup 和 Selenium 时&#xff0c;处理 href"javascript:;" 的链接需要一些额外的步骤&#xff0c;因为这些链接不直接指向一个 URL&#xff0c;而是通过 JavaScript 代码来执行某些操作。这可能包括导航到另一个页面、触发模态窗口、显示/隐藏内容等…

网站推广的概念解聘 人力资源网站上怎么做

最小二乘法&#xff08;Least Squares&#xff09;是一种用于寻找线性回归模型的最佳拟合直线的标准方法。它通过最小化数据点与拟合直线之间的平方差来找到最佳拟合的线性模型。 线性回归模型 假设我们有一组数据点 (xi,yi)&#xff0c;线性回归模型的目标是找到系数 w 和截…

仿牌网站服务器官网 wordpress

为了让小伙伴们了解到服务器主机安全受到危害的严重性&#xff0c;以下详细说明一下&#xff1a;1. 数据泄露&#xff1a;如果服务器主机遭受攻击&#xff0c;攻击者可能会窃取敏感数据&#xff0c;如用户数据、商业秘密、机密文件等&#xff0c;导致数据泄露和商业机密的泄漏。…

建什么类型个人网站比较好苏州建设工程材料信息价

前言 随着人工智能技术的迅猛发展&#xff0c;图像生成已经成为AI研究领域中的一个重要方向。OpenAI推出的DALL-E 2无疑是其中的佼佼者。这一强大的生成模型能够根据文本描述生成高质量的图像&#xff0c;为创意工作者和各行各业的专业人士提供了全新的工具。本文将深入探讨DA…