public static bool Test1() { System.Random ran = new System.Random(2134); //%%if IsEx==0 ( BList <int> list1 = new BList <int>(); Gen::List <int> list2 = new System.Collections.Generic.List <int>(); //%%elif IsEx==1 BListEx <TestElement> list1 = new BListEx <TestElement>(); Gen::List <TestElement> list2 = new System.Collections.Generic.List <TestElement>(); //%%) const int N = 10000; for (int i = 0; i < N; i++) { //%%if IsEx==0 ( int n = (int)(ran.NextDouble() * 10000); //%%elif IsEx==1 TestElement n = new TestElement((int)(ran.NextDouble() * 10000)); //%%) list1.Add(n); list2.Add(n); } for (int i = 0; i < N; i++) { if (list1[i] != list2[i]) { return(false); } } return(true); }
static bool Test2() { System.Random ran = new System.Random(2134); { //%%if IsEx==0 ( BList <int> list1 = new BList <int>(); Gen::List <int> list2 = new System.Collections.Generic.List <int>(); //%%elif IsEx==1 BListEx <TestElement> list1 = new BListEx <TestElement>(); Gen::List <TestElement> list2 = new System.Collections.Generic.List <TestElement>(); //%%) const int N = 100000; for (int i = 0; i < N; i++) { int idx = (int)(ran.NextDouble() * list1.Count); //%%if IsEx==0 ( list1.Insert(idx, i); list2.Insert(idx, i); //%%elif IsEx==1 TestElement e = new TestElement(i); list1.Insert(idx, e); list2.Insert(idx, e); //%%) } for (int i = 0; i < N; i++) { if (list1[i] != list2[i]) { return(false); } } for (int i = 0; i < N / 2; i++) { int idx = (int)(ran.NextDouble() * list1.Count); list1.RemoveAt(idx); list2.RemoveAt(idx); } for (int i = 0; i < N / 2; i++) { if (list1[i] != list2[i]) { return(false); } } } return(true); }
static bool Test2a() { System.Random ran = new System.Random(2134); { //%%if IsEx==0 ( BList <int> list1 = new BList <int>(); //%%elif IsEx==1 BListEx <TestElement> list1 = new BListEx <TestElement>(); //%%) const int N = 1000000; for (int i = 0; i < N; i++) { int idx = (int)(ran.NextDouble() * list1.Count); //%%if IsEx==0 ( list1.Insert(idx, i); //%%elif IsEx==1 TestElement e = new TestElement(i); list1.Insert(idx, e); //%%) if (i % 1000 == 0) { list1.DbgCheckState(); } } for (int i = 0; i < N / 2; i++) { int idx = (int)(ran.NextDouble() * list1.Count); list1.RemoveAt(idx); if (i % 1000 == 0) { list1.DbgCheckState(); } } list1.DbgCheckState(); } return(true); }