java - 从队列头部移除时间相关
问题描述
如果我有someObject
public class someObject
{
String objName;
int removeTime;
//---------------------------------------
//Constructor
public someObject(String objName, int removeTime)
{
this.objName = objName;
this.removeTime = removeTime;
}
//---------------------------------------
}
在 中main
,我想在Queue
和remove()
之后添加一些这些对象removeTime
。
import java.util.*;
public class App {
public static Queue<someObject> s = new LinkedList<someObject>();
//---------------------------------------------------------------
public static void main(String[] args)
{
s.add(new someObject("Harry", 10));
s.add(new someObject("Jimmy", 5));
s.add(new someObject("Tim", 2));
//print s.remove() if time(seconds) == s.peek().removeTime
//print full remaining
}
//---------------------------------------------------------------
}
实现remove()
队列功能的最佳方法是什么Time
?
解决方案
推荐阅读
- jquery - 模态作为 ViewComponent 不显示数据
- airflow - 对于 Apache Airflow,通过 CLI 手动触发 DAG 时如何传递参数?
- javascript - 在 IE 以外的其他浏览器上工作的模板文字
- selenium - Selenium 网格实现问题 - 无法运行并行浏览器
- java - 调用枚举变量时格式化它们
- node.js - 打包软件的想法
- python-3.x - 在这种情况下使用枚举是否合理?
- angular - angular 2/4 或 Typescript 中的 forEach 和 for 循环有什么区别?
- angular5 - 如何区分角度6中的组件
- android - 无法在 Android 模拟器上安装 ARCore