Пример #1
0
        static void Main(string[] args)
        {
            Iterator        iterator;
            IListCollection list = new ConcreteList();

            iterator = list.GetIterator();

            while (iterator.MoveNext())
            {
                int i = (int)iterator.GetCurrent();
                Console.WriteLine(i.ToString());
                iterator.Next();
            }
            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("迭代器模式:");
            IListCollection list     = new ConcreteList();
            var             iterator = list.GetIterator();

            while (iterator.MoveNext())
            {
                string i = (string)iterator.GetCurrent();
                Console.WriteLine(i);
                iterator.Next();
            }

            Console.Read();
        }
Пример #3
0
        static void Main(string[] args)
        {
            IIterator iterator;
            IList list = new ConcreteList();
            iterator = list.GetIterator();
            while (iterator.MoveNext())
            {
                int i = (int)iterator.CurrentItem();
                Console.WriteLine(i.ToString());

                iterator.Next();
            }

            Persons arrPersons = new Persons("Michel", "Christine", "Mathieu", "Julien");

            foreach (string s in arrPersons)
            {
                Console.WriteLine(s);
            }
            Console.Read();
        }
 public ConcreteIterator(ConcreteList list)
 {
     _list  = list;
     _index = 0;
 }
 public ConcreteIterator(ConcreteList list)
 {
     this.list = list;
     index     = 0;
 }
Пример #6
0
 public ConcreteIterator(ConcreteList list)
 {
     this.list = list;
     index = 0;
 }