Esempio n. 1
0
        static void Main(string[] args)
        {
            Aggregate aggregate = new ConcreteAggregate();

            aggregate[0] = "Zero";
            aggregate[1] = "One";
            aggregate[2] = "Two";
            Iterator iterator = aggregate.CreateIterator();

            for (object i = iterator.First(); !iterator.IsDone(); i = iterator.Next())
            {
                Console.WriteLine(i);
            }
        }
Esempio n. 2
0
        public void Start()
        {
            ConcreteAggregate aggr = new ConcreteAggregate();

            aggr[0] = "Hello ";
            aggr[1] = "Iterator ";
            aggr[2] = "Design ";
            aggr[3] = "Pattern";

            // Create Iterator and provide aggregate

            Iterator i = aggr.CreateIterator();

            object item = i.First();

            while (item != null)
            {
                Console.Write(item);
                item = i.Next();
            }
            Console.WriteLine();
        }