JDK源码阅读(2):Queue

Queue

version:1.8

不同于Stack类提供的栈的具体实现,Queue为JDK提供的队列先进先出)的接口

/**
 * @see java.util.Collection
 * @see LinkedList
 * @see PriorityQueue
 * @see java.util.concurrent.LinkedBlockingQueue
 * @see java.util.concurrent.BlockingQueue
 * @see java.util.concurrent.ArrayBlockingQueue
 * @see java.util.concurrent.LinkedBlockingQueue
 * @see java.util.concurrent.PriorityBlockingQueue
 * **/
public interface Queue<E> extends Collection<E> 

其定义了六个方法,分为两类,每类三个(进,出,查看队首元素),两类方法的区别主要在于对队列为空(添加失败) 时的处理方法。

第一类:队列为空时返回null

添加失败(非添加元素原因)返回false
队列为空返回null

/**
  * @return {@code true} if the element was added to this queue, else
  *         {@code false}
  * @throws ClassCastException if the class of the specified element
  *         prevents it from being added to this queue
  * @throws NullPointerException if the specified element is null and
  *         this queue does not permit null elements
  * @throws IllegalArgumentException if some property of this element
  *         prevents it from being added to this queue
  */
boolean offer(E e);

//@return the head of this queue, or {@code null} if this queue is empty
E poll();

//@return the head of this queue, or {@code null} if this queue is empty
E peek();

第二类:队列为空抛出异常

若由于容量限制添加失败抛出异常IllegalStateException
队列为空抛出异常NoSuchElementException

/**
  * @return {@code true} (as specified by {@link Collection#add})
  * @throws IllegalStateException if the element cannot be added at this
  *         time due to capacity restrictions
  * @throws ClassCastException if the class of the specified element
  *         prevents it from being added to this queue
  * @throws NullPointerException if the specified element is null and
  *         this queue does not permit null elements
  * @throws IllegalArgumentException if some property of this element
  *         prevents it from being added to this queue
  */
boolean add(E e);

//@return the head of this queue
//@throws NoSuchElementException if this queue is empty
E remove();

//@return the head of this queue
//@throws NoSuchElementException if this queue is empty
E element();
基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CNN硬件加速器入门级项目),该项目是个人毕设项目,答辩评审分达到98分,代码都经过调试测试,确保可以运行!欢迎下载使用,可用于小白学习、进阶。该资源主要针对计算机、通信、人工智能、自动化等相关专业的学生、老师或从业者下载使用,亦可作为期末课程设计、课程大作业、毕业设计等。项目整体具有较高的学习借鉴价值!基础能力强的可以在此基础上修改调整,以实现不同的功能。 基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CNN硬件加速器入门级项目)基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CNN硬件加速器入门级项目)基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CNN硬件加速器入门级项目)基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CNN硬件加速器入门级项目)基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CNN硬件加速器入门级项目)基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CNN硬件加速器入门级项目)基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CNN硬件加速器入门级项目)基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CNN硬件加速器入门级项目)基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CNN硬件加速器入门级项目)基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CNN硬件加速器入门级项目)基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CNN硬件加速器入门级项目)基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CNN硬件加速器入门级项目)基于PYNQ-Z2实现手写数字识别卷积神经网络硬件加速器源代码(CN
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值