Question: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LinkListExample { public class OurList { private class OurListNode { public T Data { get; set;

 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LinkListExample { using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LinkListExample { public class OurList { private class OurListNode { public T Data { get; set; } public OurListNode Next { get; set; } public OurListNode(T paramData = default(T), OurListNode paramNext = null) { this.Data = paramData; this.Next = paramNext; } } private OurListNode first; public OurList() { first = null; } public void Clear() // shown in class notes { first = null; } public T[] ToArray() { // complete this method, turn in just this method } public void AddFirst(T data) // shown in class notes { this.first = new OurListNode(data, this.first); } public void RemoveFirst() // shown in class notes { if (first != null) first = first.Next; } public void AddLast(T data) // shown in class notes { if (first == null) AddFirst(data); else { OurListNode pTmp = first; while (pTmp.Next != null) pTmp = pTmp.Next; pTmp.Next = new OurListNode(data, null); } } public void RemoveLast() // shown in class notes { if (first == null) return; else if (first.Next == null) RemoveFirst(); else { OurListNode pTmp = first; while (pTmp.Next != null && pTmp.Next.Next != null) pTmp = pTmp.Next; pTmp.Next = null; } } public void Display() // shown in class notes { OurListNode pTmp = first; while (pTmp != null) { Console.Write("{0}, ", pTmp.Data); pTmp = pTmp.Next; } Console.WriteLine(); } public bool IsEmpty() // shown in class notes { if (first == null) return true; else return false; } } } 

Complete the ToArray method to OurList class below that returns an array containing all of the elements in this list in proper sequence (from first to last element). Test your method in a main routine in a different class (e.g. don't put a main routine in the list class). Do not turn in the code below. Turn in your Toray method and the main routine from the other class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!