如果我有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()
的功能的最佳方法是什么?