public static void Main() { var list = new List <int>(); list.Add(1); list.Add(2); list.Add(3); list.Add(4); list.Add(5); list.Add(6); list.Add(7); list.Add(8); list.Add(9); list.Add(10); list.Delete(10); list.Delete(1); list.Delete(5); foreach (var element in list) { Console.WriteLine(element); } list.Delete(2); list.Delete(9); list.Delete(4); list.Delete(7); Console.WriteLine(); foreach (var element in list) { Console.WriteLine(element); } }
static void Main(string[] args) { List LST = new List(); bool[] no_yes = new bool[] { false, true }; for (int i = 0; i < no_yes.Length; i++) { bool eneble_shuffle = no_yes[i]; for (int j = 0; j < LST.ns.Length; j++) { var arr = LST.FillIncreasing(LST.ns[j]); if (eneble_shuffle) { LST.Shuffle(ref arr); } DateTime insertion_start = DateTime.Now; for (int k = 0; k < arr.Length; k++) { Node iter = LST.Insert(arr[k]); Debug.Assert(iter != null); Debug.Assert(iter.value == arr[k]); } DateTime insertion_stop = DateTime.Now; var insertion_time = insertion_stop - insertion_start; LST.Shuffle(ref arr); DateTime search_start = DateTime.Now; for (int k = 0; k < arr.Length; k++) { Node iter = LST.Search(arr[k]); Debug.Assert(iter != null); Debug.Assert(iter.value == arr[k]); } DateTime search_stop = DateTime.Now; var search_time = search_stop - search_start; LST.Shuffle(ref arr); for (int k = 0, l = arr.Length; k < arr.Length; k++, l--) { Debug.Assert(LST.Size() == l); LST.Delete(arr[k]); } Debug.Assert(LST.Size() == 0); Debug.Assert(LST.head == null); Console.WriteLine("{0}, {1}, {2}, {3}", arr.Length, no_yes[i], insertion_time, search_time); } } }