/*[Test] * public void find25thElementIn100() * { * tml.setTestCaseName("Find elements in 100"); * * SList<Payload> list = this.creatAlistWithNelement(100); * Payload toBeFound_25 = new Payload("Load 25"); * Payload toBeFound_50 = new Payload("Load 50"); * Payload toBeFound_75 = new Payload("Load 75"); * Payload toBeFound_100 = new Payload("Load 100"); * tml.setInitialTimeAndMemory(); * list. * list.contains(toBeFound_25); * tml.logTimeAndMemoryUsage(25); * list.contains(toBeFound_50); * tml.logTimeAndMemoryUsage(50); * list.contains(toBeFound_75); * tml.logTimeAndMemoryUsage(75); * list.contains(toBeFound_100); * tml.logTimeAndMemoryUsage(100); * * }*/ private SList <Payload> creatASListWithNelement(int numberOfElements) { SList <Payload> list; Payload firstElement = new Payload("Load 0"); list = SList <Payload> .New(firstElement); for (int i = 1; i < numberOfElements; i++) { list += new Payload("Load " + i); } return(list); }
private void reusableSlistTestCase(String caseName, int numberOfElements) { tml.setTestCaseName(caseName); SList <Payload> list; Payload firstElement = new Payload("Load 0"); tml.setInitialTimeAndMemory(); list = SList <Payload> .New(firstElement); tml.logTimeAndMemoryUsage(1); for (int i = 1; i < numberOfElements; i++) { (SList <Payload> operand, int pos)prevList = (SList <Payload> .New(new Payload("Load " + i)), i); //list = list + prevList; //list = list + (SList<Payload>.New(new Payload("Load " + i)), i); //list.InsertAt(new Payload("Load "+i), 0); tml.logTimeAndMemoryUsage(i + 1); } }
static void Main(string[] args) { // Tests for SList (unordered list) var sl = SList <string> .New("Red", "Blue", "Green"); sl = sl.InsertAt("Yellow", 0); var s2 = sl; sl = sl.RemoveAt(3); sl = sl.UpdateAt("Pink", 1); sl = sl.InsertAt("Orange", 2); Check <string>(sl.ToArray(), "Yellow", "Pink", "Orange", "Blue"); Check <string>(s2.ToArray(), "Yellow", "Red", "Blue", "Green"); Console.WriteLine("SList done"); // Tests for SArray var sa = new SArray <string>("Red", "Blue", "Green"); sa = sa.InsertAt(0, "Yellow"); sa = sa.RemoveAt(3); var sb = sa; sa = sa.InsertAt(2, "Orange", "Violet"); Check(sa.ToArray(), "Yellow", "Red", "Orange", "Violet", "Blue"); Check(sb.ToArray(), "Yellow", "Red", "Blue"); Console.WriteLine("SArray done"); // Tests for SSearchTree<string> var ss = SSearchTree <string> .New("InfraRed", "Red", "Orange", "Yellow", "Green", "Blue", "Violet"); Check(ss.ToArray(), "Blue", "Green", "InfraRed", "Orange", "Red", "Violet", "Yellow"); var si = SSearchTree <int> .New(56, 22, 24, 31, 23); Check(si.ToArray(), 22, 23, 24, 31, 56); Console.WriteLine("SSearchTree done"); // Tests for SDict var sd = SDict <string, string> .Empty; sd = sd.Add("Y", "Yellow"); sd = sd.Add("G", "Green"); sd = sd.Add("B", "Blue"); sd = sd.Remove("G"); var sr = new string[sd.Count]; var j = 0; for (var b = sd.First(); b != null; b = b.Next()) { sr[j++] = b.Value.key + ": " + b.Value.val; } Check(sr, "B: Blue", "Y: Yellow"); Console.WriteLine("SDict done"); // Tests for SMTree var ti = SList <TreeInfo> .Empty; ti = ti.InsertAt(new TreeInfo("0", 'D', 'D'), 0); // onDuplicate must be Disallow on all except last entry ti = ti.InsertAt(new TreeInfo("1", 'A', 'A'), 1); var sm = new SMTree(ti); var test = new string[] { "BALTIM", "ANNU", "A", "ANNO", "BALTIC", "BRAIL" }; for (var i = 0; i < test.Length; i++) { sm = Add(sm, test[i], i); } var sorted = new string[test.Length]; j = 0; for (var b = sm.First(); b != null; b = b.Next()) { sorted[j++] = test[((MTreeBookmark)b).value()]; } // we are only sorting on the first two letters! // Check() we should offer some alternatives here Check(sorted, "A", "ANNU", "ANNO", "BALTIM", "BALTIC", "BRAIL"); Console.WriteLine("SMTree done"); File.Delete("strong"); File.Create("strong").Close(); var d = SDatabase.Open("strong"); var tr = new STransaction(d); tr = new STransaction(tr, new SString("This is Strong")); tr = new STransaction(tr, new STable(tr, "tbl")); var c = tr.Commit(); d.Close(); d = SDatabase.Open("strong"); Console.WriteLine(d.objects.First().Value.val.ToString()); Console.ReadKey(); }