Example #1
0
        static void Main(string[] args)
        {
            // Build a collection
            Collection collection = new Collection();

            collection[0] = new Employee("Tran Quang A");
            collection[1] = new Employee("Le Nhat B");
            collection[2] = new Employee("Le Van C");
            collection[3] = new Employee("Tran Van D");
            collection[4] = new Employee("Tao Nhu C");

            // Create iterator
            Iterator iterator = collection.CreateIterator();

            Console.WriteLine("Iterating over collection:");

            // Get current Employee
            var itemCurrent = iterator.Current();

            while (iterator.HasNext)
            {
                var item = iterator.Next();
                Console.WriteLine(item.Name);
            }

            Console.ReadKey();
        }
Example #2
0
        static void Main(string[] args)
        {
            var history = new BrowseHistory();

            history.Push("a");
            history.Push("b");
            history.Push("c");

            Iterator <string> iterator = history.CreateInterator();

            while (iterator.HasNext())
            {
                Console.WriteLine(iterator.Current());
                iterator.Next();
            }

            Console.ReadKey();
        }