public void InsertNode(T a) { if (start == null) { start = new SNode <T>(a); length++; return; } SNode <T> current = start; while (current.Next != null) { current = current.Next; } current.Next = new SNode <T>(a); length++; }
public void InsertNode(T a, int i) { SNode <T> current; SNode <T> previous; if (i < 1 || i > length + 1) { Console.WriteLine("Position is error!"); return; } SNode <T> newnode = new SNode <T>(a); if (i == 1) { newnode.Next = start; start = newnode; length++; return; } current = start; previous = null; int j = 1; while (current != null && j < i) { previous = current; current = current.Next; j++; } if (j == i) { previous.Next = newnode; newnode.Next = current; length++; } }
public T SearchNode(T value) { if (IsEmpty()) { Console.WriteLine("List is empty!"); return(default(T)); } SNode <T> current = start; int i = 1; while (!current.Data.ToString().Contains(value.ToString()) && current != null) { current = current.Next; i++; } if (current != null) { return(current.Data); } else { return(default(T)); } }
public SLinkList() { start = null; }
public SNode() { data = default(T); next = null; }
public SNode(T val) { data = val; next = null; }
public void Clear() { start = null; }
public SNode(SNode <T> p) { next = p; }
public SNode(T val, SNode <T> p) { data = val; next = p; }