pqueue.java

来自「PEPA模型性能分析工具」· Java 代码 · 共 92 行

JAVA
92
字号
package trans;
import semantic.Process;

public class PQueue {
	PNode node;
	PQueue next;
	private static int count=0;
	public PQueue()
	{
		node=null;
		next=null;
		count=0;
	}
	public int Count()
	{
		return count;
	}
	public int find(Process o)
	{
		Process pro;
		PNode p;
		PQueue q=this;
		while(q.next!=null)
		{
			p=q.node;
			pro=p.value;
			if(pro.equals(o))
				return p.id;
			q=q.next;
		}
		p=q.node;
		pro=p.value;
		if(pro.equals(o))
			return p.id;
		return 0;
		
	}
	public String find(int i)
	{
		PQueue pos=this;
		int j=1;
		while(j<count&&pos!=null)
		{
			if(j==i) break;
			j++;
			pos=pos.next;
		}
		PNode n=pos.node;
		if(n!=null)
		{
			return i+":\t"+n.toString();
		}
		else
			return null;
	}
	public PQueue(PNode n)
	{
		node=n;
		next=null;
	}
	public int put(Process o)
	{
		PNode p;
		Process pro;
		if(node==null)
		{	
			node=new PNode(o,++count);
			return count;
		}
		else
		{
			PQueue q=this;
			
			while(q.next!=null)
			{
				p=q.node;
				pro=p.value;
				if(pro.equals(o))
					return p.id;
				q=q.next;
			}
			p=q.node;
			pro=p.value;
			if(pro.equals(o))
				return p.id;
			
			q.next=new PQueue(new PNode(o,++count));
			return count;
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?