예제 #1
0
 private void DeleteFromList(LinkedListTwoWay <long> list)
 {
     while (!list.IsEmpty())
     {
         Console.WriteLine("delete: " + list.RemoveFirst());
     }
 }
예제 #2
0
        private void FillList(LinkedListTwoWay <long> list)
        {
            Random rnd = new Random();

            for (int i = 0; i < 10; i++)
            {
                long item = rnd.Next(100, 999);
                list.AddFirst(item);
            }
        }
예제 #3
0
        public void Run()
        {
            LinkedListTwoWay <long> list = new LinkedListTwoWay <long>();

            Console.WriteLine("Fill list");
            FillList(list);
            var iter  = list.GetIterator();
            int count = 1;

            while (true)
            {
                if (count % 10 == 0)
                {
                    Console.WriteLine();
                }
                var it = iter.GetCurrent();
                Console.Write(it + " ");
                bool res = iter.MoveNext();
                if (res == false)
                {
                    break;
                }
                count++;
            }
            iter.Reset();
            Console.WriteLine("End");
            iter.MoveNext();
            iter.MoveNext();
            iter.AddBefore(20L);
            iter.MoveNext();
            iter.MoveNext();
            iter.AddAfter(15L);

            list.RemoveKey(15L);

            list.AddLast(1);
            list.AddLast(2);
            list.AddLast(3);
            list.AddLast(4);
            list.AddLast(5);

            DeleteFromList(list);
        }
예제 #4
0
 public IteratorTwoList(LinkedListTwoWay <T> list)
 {
     _list = list;
     Reset();
 }