public void addSorted(MLink mTargetNode) { Debug.Assert(mTargetNode != null); mTargetNode.wash(); TimerEvent mTargetEvent = (TimerEvent)mTargetNode; Debug.Assert(mTargetEvent != null); if (this.activeList == null) { activeList = mTargetNode; } else { // Add to sorted list MLink mCurrNode = this.activeList; Debug.Assert(mCurrNode != null); while (mCurrNode != null) { TimerEvent mCurrEvent = (TimerEvent)mCurrNode; if (mTargetEvent.cTriggerTime <= mCurrEvent.cTriggerTime) { if (mCurrEvent.pPrev != null) { mCurrEvent.pPrev.pNext = mTargetEvent; mTargetEvent.pPrev = mCurrEvent.pPrev; mTargetEvent.pNext = mCurrEvent; mCurrEvent.pPrev = mTargetEvent; } else { mCurrNode.pPrev = mTargetNode; mCurrNode.pPrev.pNext = mCurrNode; activeList = mTargetNode; } break; } if (mCurrNode.pNext == null) { mCurrNode.pNext = mTargetNode; mTargetNode.pPrev = mCurrNode; break; } mCurrNode = mCurrNode.pNext; } //genericPrint(); } }
// remove a node from active and add it to reserve protected void genericRemove(MLink dataNode) { Debug.Assert(dataNode != null); // remove from active MLink.removeNode(dataNode, ref this.activeList); //wash the data node dataNode.wash(); //add it to reserve list MLink.addToFront(dataNode, ref this.reserveList); mNumActiveNodes--; mNumReserveNodes++; }
public MLink pullReserveNode() { if (reserveList == null) { fillReserve(deltaRefillCount); } Debug.Assert(reserveList != null); MLink dataNode = reserveList; Debug.Assert(dataNode != null); reserveList = reserveList.pNext; dataNode.wash(); return(dataNode); }
// remove the head node of the list public static MLink removeFromFront(ref MLink listHead) { Debug.Assert(listHead != null); MLink linkNode = listHead; listHead = listHead.pNext; if (listHead != null) { listHead.pPrev = null; } linkNode.wash(); return(linkNode); }