zoukankan      html  css  js  c++  java
  • queue队列

    Queue常用方法:

    • queues.add("1");// 尾插--集合中添加元素
    • String str = queues.peek();// 返回头--返回此队列的头
    • queues.poll();// 头删--检索并删除此队列的头
    • queues.offer("4");// 尾插--将指定的元素插入此队列尾部
    • queues.remove();// 头删-- 检索并删除此队列的头
    • queues.remove("4");// 删除指定--从中删除指定元素的单个实例
    • boolean isNull = queues.isEmpty();// 判空--集合是否为空
    • queues.clear();// 清除集合--删除此集合中的所有元素,此方法返回后,集合将为空。
     public static void queueTest() {
            // 队列继承Collection
            Queue<String> queues = new LinkedList<>();
            queues.add("1");// 集合中添加元素
            queues.add("2");
            queues.add("3");
            String str = queues.peek();// 返回此队列的头
            System.out.println("此队列的头str:" + str);
            queues.poll();// 检索并删除此队列的头>>Retrieves and removes the head of this queue
            queues.offer("4");// 如果可能,请将指定的元素插入此队列
            queues.remove();// 检索并删除此队列的头
            queues.remove("4");// 从中删除指定元素的单个实例
            boolean isNull = queues.isEmpty();// 集合是否为空
            System.out.println("isNull" + isNull);
            queues.clear();// 删除此集合中的所有元素,此方法返回后,集合将为空。
            isNull = queues.isEmpty();// 集合是否为空
            System.out.println("isNull" + isNull);
        }
  • 相关阅读:
    crontab机会任务监控
    Python 模块的一般处理
    MySQLdb autocommit
    MySQLdb callproc 方法
    Pthon MySQLdb 的安装
    CentOS7安装MySQL
    Linux中的网络
    Linux中的盘符问题
    类比的方法学习Performance_schema
    MySQL 设置数据库的隔离级别
  • 原文地址:https://www.cnblogs.com/mjtabu/p/13385328.html
Copyright © 2011-2022 走看看