//==================================================================== // 读取上次读取后的下一个元素,不执行DeQueue操作 //==================================================================== public QueueElement GetNext() { if (pLastAccess != null) { pLastAccess = pLastAccess.next; } return(pLastAccess); }
//==================================================================== // 从队列中取出前面的一个元素 //==================================================================== public QueueElement DeQueue() { if (pHead == null) { return(null); } QueueElement pRet = pHead; pHead = pHead.next; return(pRet); }
//==================================================================== // 将QueueElement根据eWeight由小到大的顺序插入队列 //==================================================================== public void EnQueue(QueueElement newElement) { QueueElement pCur = pHead, pPre = null; while (pCur != null && pCur.eWeight < newElement.eWeight) { pPre = pCur; pCur = pCur.next; } newElement.next = pCur; if (pPre == null) pHead = newElement; else pPre.next = newElement; }
//==================================================================== // 将QueueElement根据eWeight由小到大的顺序插入队列 //==================================================================== public void EnQueue(QueueElement newElement) { QueueElement pCur = pHead, pPre = null; while (pCur != null && pCur.eWeight < newElement.eWeight) { pPre = pCur; pCur = pCur.next; } newElement.next = pCur; if (pPre == null) { pHead = newElement; } else { pPre.next = newElement; } }
//==================================================================== // 读取第一个元素,但不执行DeQueue操作 //==================================================================== public QueueElement GetFirst() { pLastAccess = pHead; return pLastAccess; }
//==================================================================== // 从队列中取出前面的一个元素 //==================================================================== public QueueElement DeQueue() { if (pHead == null) return null; QueueElement pRet = pHead; pHead = pHead.next; return pRet; }
//==================================================================== // 清除所有元素 //==================================================================== public void Clear() { pHead = null; pLastAccess = null; }
//==================================================================== // 读取上次读取后的下一个元素,不执行DeQueue操作 //==================================================================== public QueueElement GetNext() { if (pLastAccess != null) pLastAccess = pLastAccess.next; return pLastAccess; }
//==================================================================== // 读取第一个元素,但不执行DeQueue操作 //==================================================================== public QueueElement GetFirst() { pLastAccess = pHead; return(pLastAccess); }