public static void Main() { LayeredLinkedList <int> lll = new LayeredLinkedList <int>(0, x => (double)x, 1000, 100, 10, 1); BulletHell.Time.Timer time = new BulletHell.Time.Timer(); Random r = new Random(); time.Reset(); long thous = 1000; long million = thous * thous; long billion = thous * million; long trillion = million * million; for (long i = 0; i < 20 * thous; i++) { int j = r.Next(10); lll.Add(j); lll.Remove(j); //lll.Remove(r.Next(10)); //lll.Add(1000 * r.NextDouble()); } Console.WriteLine(lll.Count()); Console.WriteLine(time.Time); //lll.Write(); Console.WriteLine("-------------------------------------------------"); time.Reset(); int count = 0; foreach (double d in lll.ElementsBetween(30, 40)) { count++; } Console.WriteLine(count); count = 0; foreach (double d in lll.ElementsBetween(-100, 5000)) { if (30 < d && d < 40) { count++; } } Console.WriteLine(count); Console.WriteLine(time.Time); Console.ReadKey(); }
public LLLGuide(LayeredLinkedList <S> list, bool beginning = true) { trail = new SimpleLinkedList <LinkedListNode <LayeredLinkedList <S> > >(); if (list.Count() == 0) { throw new InvalidOperationException("List has no elements to guide through"); } LinkedListNode <LayeredLinkedList <S> > lists; if (beginning) { while (list.layers != 0) { lists = list.nextLevel.First; while (lists.Value.Count() == 0) { lists = lists.Next; } trail = trail.Push(lists); list = lists.Value; } current = list.vals.First; } else { while (list.layers != 0) { lists = list.nextLevel.Last; while (lists.Value.Count() == 0) { lists = lists.Previous; } trail = trail.Push(lists); list = lists.Value; } current = list.vals.Last; } }