public static void RemoveFromList(ref DLink pCurrentHead, DLink pNodeToRemove) { Debug.Assert(pNodeToRemove != null); DLink pTmpNode = pNodeToRemove; // If pNode is head of list if (pCurrentHead == pNodeToRemove) { pCurrentHead = pCurrentHead.GetNext(); if (pCurrentHead != null) { // Set prev to null - it's the new list head pCurrentHead.SetPrev(null); } } else { if (pTmpNode.GetPrev() != null) { // Set the previous node's next to pNode's next pTmpNode.GetPrev().SetNext(pNodeToRemove.GetNext()); } if (pTmpNode.GetNext() != null) { // Set the next node's prev to pNodes prev pTmpNode.GetNext().SetPrev(pTmpNode.GetPrev()); } } }
protected DLink BaseGetNodeFromReserve() { // If pReserve is empty, refill with growDelta if (pReserve == null) { AddToReservedList(this.growDelta); } // Get and remove head of pReserve (as pNode) Debug.Assert(pReserve != null); DLink pNodeToActivate = pReserve; // Set new head of Reserve pReserve = pReserve.GetNext(); // If new head is not null, clear its previous link to newly activated node if (pReserve != null) { pReserve.SetPrev(null); } // "Clean" values of pNode pNodeToActivate.Clean(); return(pNodeToActivate); }
public virtual void Print() { DLink pNode = this.pHead; while (pNode != null) { Debug.Write(pNode + ", "); pNode = pNode.GetNext(); } Debug.WriteLine(""); }
public virtual void Notify() { DLink pNode = this.pHead; while (pNode != null) { // Fire off listener ((Observer)pNode).Update(this); pNode = pNode.GetNext(); } }
public virtual void PurgeAll() { DLink pNode = this.pHead; DLink pTmp = null; while (pHead != null) { // hold next, delete current, pass next to current pTmp = pNode.GetNext(); DLink.Remove(ref this.pHead, pNode); pNode = pTmp; } }
public override void Print() { Debug.WriteLine(" GameObject Name: {0} ({1})", this.GetName(), this.GetHashCode()); base.Print(); DLink pNode = pHead; while (pNode != null) { pNode.Print(); pNode = pNode.GetNext(); } }
public override Component GetLastChild() { DLink pNode = this.poHeadChild; DLink pTmp = null; while (pNode != null) { pTmp = pNode; pNode = pNode.GetNext(); } return((Component)pTmp); }
public override string ToString() { String returnVal = String.Format("[Composite Component: ({0})", this.GetHashCode()); DLink pNode = this.poHeadChild; while (pNode != null) { returnVal += pNode.ToString(); returnVal += ", "; pNode = pNode.GetNext(); } return(returnVal + " ]\n"); }
public override string ToString() { String returnVal = "[GameObjectComposite: " + base.ToString(); DLink pNode = this.poHeadChild; while (pNode != null) { returnVal += pNode.ToString(); returnVal += ", "; pNode = pNode.GetNext(); } return(returnVal + " ]\n"); }
protected DLink BaseFind(DLink refNode) { DLink tmpNode = pActive; while (tmpNode != null) { if (CompareTo(tmpNode, refNode)) { break; } tmpNode = tmpNode.GetNext(); } return(tmpNode); }
public override void Move(float xDelta, float yDelta) { DLink pNode = this.pHead; while (pNode != null) { // Get component Component pComponent = (Component)pNode; // Move component pComponent.Move(xDelta, yDelta); // Increment pointer along list pNode = pNode.GetNext(); } }
public void DetachAllObservers() { DLink pNode = this.head; DLink pTmpNode; while (pNode != null) { // Walk through the list pTmpNode = pNode; pNode = pNode.GetNext(); // Clear and remove node Debug.Assert(pTmpNode != null); DLink.RemoveFromList(ref this.head, pTmpNode); pTmpNode = null; } }
//---------------------------------------------------------------------- // Private methods //---------------------------------------------------------------------- private void ClearList(DLink listHead) { DLink pNode; DLink pTmpNode; pNode = listHead; while (pNode != null) { // Walk through the list pTmpNode = pNode; pNode = pNode.GetNext(); // Clear and remove node Debug.Assert(pTmpNode != null); this.DerivedDestroyNode(pTmpNode); DLink.RemoveFromList(ref listHead, pTmpNode); pTmpNode = null; } }
public Composite GetChildByIndex(int index) { Debug.Assert(index >= 0); Debug.Assert(index < numChildren); DLink pNode = this.pHead; int count = 0; while (count <= index) { if (count == index) { return((Composite)pNode); } pNode = pNode.GetNext(); count++; } return(null); }
private void ClearList(DLink listHead) { DLink pNode; DLink pTmpNode; pNode = listHead; while (pNode != null) { // Walk through the list pTmpNode = pNode; pNode = pNode.GetNext(); // Clear and remove node Debug.Assert(pTmpNode != null); this.DerivedDestroyNode(pTmpNode); DLink.RemoveFromList(ref this.pActive, pTmpNode); pTmpNode = null; // Decrement total count this.totalNodeNum--; } }
public override void Move(float dummyX, float dummyY) { DLink pNode = this.pHead; // #1 - Initial movement since wall collision - Move down if (switchXDirection && !directionChangePending) { this.SetXDelta(0.0f); this.SetYDelta(-25.0f); this.directionChangePending = true; } while (pNode != null) { // Get component Component pComponent = (Component)pNode; // Move component pComponent.Move(this.xDelta, this.yDelta); pNode = pNode.GetNext(); } // #3 - Finally, Grid has moved off wall, reset direction change flag if (directionChangePending && !switchXDirection) { this.directionChangePending = false; } // #2 - Movement down complete, switch X direction if (switchXDirection == true) { // Reset deltas to horizontal movement in opposite direction this.yDelta = 0.0f; this.xDelta = (this.prevXDelta * -1.0f); this.switchXDirection = false; } }
//---------------------------------------------------------------------- // Private methods //---------------------------------------------------------------------- private DLink FindGameObjectByReference(DLink pSearchGameObject) { // If no nodes in Active list if (pActive == null) { return(null); } // Iterate over active list, starting at head DLink pSearchIterator = pActive; while (pSearchIterator != null) { // Compare current node to provided DLink node. If match, return node if (HashCodeCompare(pSearchIterator, pSearchGameObject)) { return(pSearchIterator); } pSearchIterator = pSearchIterator.GetNext(); } // If no match is found return(null); }
/// <summary> /// Finds first node that matches the DLink node passed in as pNodeTarget. Returns null if no matching node is found. /// </summary> /// <param name="sd">Instance of DLink that will be compared against Active list nodes using derivedCompare()</param> /// <returns></returns> protected DLink BaseFind(DLink pNodeTarget) { // If no nodes in Active list if (pActive == null) { return(null); } // Iterate over active list, starting at head DLink pSearchIterator = pActive; while (pSearchIterator != null) { // Compare current node to provided DLink node. If match, return node if (DerivedCompare(pSearchIterator, pNodeTarget)) { return(pSearchIterator); } pSearchIterator = pSearchIterator.GetNext(); } // If no match is found return(null); }