I have tried having a look around on the web at different forums and can't decipher how to do this.
This is my Link class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LinkedListGen
{
class LinkGen<T>
{
private T data;
private LinkGen<T> next;
public LinkGen(T item)
{
data = item;
next = null;
}
public LinkGen(T item, LinkGen<T> list)
{
data = item;
next = list;
}
public T HeadList
{
set { this.data = value; }
get { return this.data; }
}
public LinkGen<T> TailList
{
set { this.next = value; }
get { return this.next; }
}
}
}
And this is my LinkedListGen class:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LinkedListGen
{
class LinkListGen<T> where T:IComparable
{
private LinkGen<T> list; //default value – empty list
int count = 0;
bool flag = false
public void AppendItem(T item) // Add items to back of list
{
LinkGen<T> temp = list;
if (temp == null)
{
list = new LinkGen<T>(item);
}
else
{
while (temp.TailList != null)
{
temp = temp.TailList;
}
temp.TailList = new LinkGen<T>(item);
}
}
public void Sort()
{
//I need the sort method here ofc.
}
public void AddItem(T item) //add item to front of list
{
list = new LinkGen<T>(item, list);
}
In the above class I do have a few more methods; RemoveItem, Concatenate, DisplayItems, Copy(Directly copy 1 lists contents to another), NumberOfItems, IsItemPresent. I only thought I should put in the methods that I think would get used just to save a massive amount of space.
Please help lol
Regards!