首页 > 解决方案 > 从队列头部移除时间相关

问题描述

如果我有someObject

public class someObject 
{
	String objName;
	int removeTime;
	//---------------------------------------
	//Constructor
	public someObject(String objName, int removeTime)
	{
		this.objName = objName;
		this.removeTime = removeTime;
	}
        //---------------------------------------
}

在 中main,我想在Queueremove()之后添加一些这些对象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

标签: javatimestack

解决方案


推荐阅读