Administrator

Administrator

  • Tech Writer
  • 2.2k
  • 1.5m

got problem with the code

Feb 24 2003 11:37 PM
using System; using System.Runtime.Serialization; namespace workflowTool { /// /// Summary description for LinkedList. /// public class LinkedList { internal class Node { internal object m_ObjectToStore; internal Node m_Next; internal Node m_Previous; public Node(object objectToStore) { m_ObjectToStore = objectToStore; } } Node m_First; internal uint m_uiNumOfObjects; // These members are used to optimize enumeration. Another way could have been to // iterate till required node is found (which is costly). internal long m_lLastAccessed; internal Node m_LastAccessed; public LinkedList() { // // TODO: Add constructor logic here // m_First = null; m_uiNumOfObjects = 0; m_lLastAccessed = -1; } public void AddToEnd(object objToAdd) { if (m_First == null) { m_First = new Node(objToAdd); m_First.m_Next = m_First; m_First.m_Previous = m_First; ++m_uiNumOfObjects; return; } Node newNode = new Node(objToAdd); // Get the previous node. Node last = m_First.m_Previous; newNode.m_Next = last.m_Next; newNode.m_Previous = last.m_Previous; last.m_Next = newNode; m_First.m_Previous = newNode; ++m_uiNumOfObjects; } public void Clear() { m_First = null; m_uiNumOfObjects = 0; m_lLastAccessed = -1; } public uint Count { get { return m_uiNumOfObjects; } } public object this[uint uiIndex] { get { if (m_LastAccessed == null) { m_LastAccessed = m_First; m_lLastAccessed = 0; return m_First.m_ObjectToStore; } if (uiIndex < 0 || uiIndex >= m_uiNumOfObjects) { throw new IndexOutOfRangeException(); } ++m_lLastAccessed; m_LastAccessed = m_LastAccessed.m_Next; return m_LastAccessed.m_ObjectToStore; } } } } sorry for not specified to you last time.i want to know what is enumeration? this part of the code is use to do what? public object this[uint uiIndex] { get { if (m_LastAccessed == null) { m_LastAccessed = m_First; m_lLastAccessed = 0; return m_First.m_ObjectToStore; } if (uiIndex < 0 || uiIndex >= m_uiNumOfObjects) { throw new IndexOutOfRangeException(); } ++m_lLastAccessed; m_LastAccessed = m_LastAccessed.m_Next; return m_LastAccessed.m_ObjectToStore; } } if i want to add a move code inside the linked list class how can i add it.i still cannot move the object from one location2another.

Answers (1)