Example #1
0
 public ConcreteIterator(MyCollection myColl)
 {
     _myColl = myColl;
 }
Example #2
0
        public static void TestIterator()
        {
            MyCollection coll = new MyCollection(5);
            coll[0] = 3;
            coll[1] = 4;
            coll[2] = 1;
            coll[3] = 2;
            coll[4] = 8;

            IIterator iterator = new ConcreteIterator(coll);
            // or
            //IIterator iterator = coll.CreateIterator();

            int item = iterator.First();
            Console.WriteLine(item);
            while (!iterator.IsDone)
            {
                item = iterator.Next();
                Console.WriteLine(item);
            }
        }