flutter 接口队列_队列接口

本文介绍了在Java中,Queue接口作为集合的一部分,用于存放待处理的元素,并遵循FIFO原则。Queue接口的方法包括插入和删除等操作。通常使用PriorityQueue和LinkedList来实现队列。此外,提到了队列接口在Flutter接口队列中的应用。
摘要由CSDN通过智能技术生成

flutter 接口队列

In Java, the Queue interface is under java.util package. The queue extends the collection interface. It is used to hold an element in a collection which are to be processed and can also perform operations like insertion, deletion etc. In this interface elements are inserted at the end of the list and deleted from the start of the list. Its follows the concept of FIFO i.e First In First Out. To declare a queue a concrete class is required, mostly PriorityQueue and LinkedList class is used.

在Java中,Queue接口位于java.util包下。 队列扩展了收集接口。 它用于将元素保留在要处理的集合中,还可以执行插入,删除等操作。在此接口中,元素插入列表的末尾,然后从列表的开头删除。 它遵循FIFO的概念,即先进先出 。 要声明队列,需要一个具体的类,主要使用PriorityQueue和LinkedList类。

下面是队列接口的方法。 ( Below is the method of Queue interface. )
S.no.MethodDescription
1add()It is used for adding elements in the queue.
2peek()It used to view the head of the queue..
3element()It is used to check whether the queue is empty or not. If empty it throws NoSuchElementFound.
4remove()It is used to remove the elements from the head of the queue.
5poll()It is used to remove an element and return the head of the queue.
6size()It is used to get the size of the element.
序号 方法 描述
1个 加() 它用于在队列中添加元素。
2 窥视() 它用来查看队列的头。
3 元件() 用于检查队列是否为空。 如果为空,则抛出NoSuchElementFound。
4 去掉() 它用于从队列的开头删除元素。
5 轮询() 它用于删除元素并返回队列的开头。
6 尺寸() 它用于获取元素的大小。

Example:

例:

import java.util.LinkedList; 
import java.util.Queue; 

public class QueueDemo1 
{ 
  public static void main(String[] args) 
  { 
    Queue<Integer> a = new LinkedList<>(); 
    for (int i=0; i<10; i++) 
a.add(i); 
System.out.println("**************************************");
System.out.println("Elements of Queue : "+a); 
System.out.println("**************************************");
int b= a.remove(); 
System.out.println("Removed element from the Queue : " + b); 
System.out.println(a); 
System.out.println("**************************************");
int c = a.peek(); 
System.out.println("head of queue-" + c); 
System.out.println("**************************************");
int d= a.size(); 
System.out.println("Size of queue-" + d); 
  } 
}
queue-example

翻译自: https://www.studytonight.com/java/queue-interface.php

flutter 接口队列

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值