コード例 #1
0
        static void Main(string[] args)
        {
            TimeTrials();

            UseTheMagicHat();

            MagicHat <Rabbit> hat = CreateHat <Rabbit>();

            hat.Fill();
            hat.Dissapear();

            Console.ReadLine();
        }
コード例 #2
0
        private static void UseTheMagicHat()
        {
            MagicHat <Rabbit> hat = new MagicHat <Rabbit>();

            hat.Put(new Rabbit {
                Name = "Fluffy"
            });
            hat.Put(new Rabbit {
                Name = "Muffy"
            });

            Rabbit firstRabbit = hat.Pull();

            Console.WriteLine(firstRabbit.Name);
        }
コード例 #3
0
        private static void UseTheMagicHat()
        {
            Console.WriteLine("Abracadabra");

            MagicHat <Rabbit> hat = new MagicHat <Rabbit>();      // instaniate a MagicHat of Rabbit

            hat.Enqueue(new Rabbit {
                Name = "Bugs"
            });                                                 // use the operations inherited Queue<T>
            hat.Enqueue(new Rabbit {
                Name = "Roger"
            });
            hat.Enqueue(new Rabbit {
                Name = "Thumper"
            });

            Rabbit firstRabbit = hat.Dequeue();
        }
コード例 #4
0
        private static void UseTheMagicHat()
        {
            MagicHat <Rabbit> rabbitHat = new MagicHat <Rabbit>(); // instaniate a MagicHat of Rabbit

            rabbitHat.Add(new Rabbit {
                Name = "Bugs"
            });
            rabbitHat.Add(new Rabbit {
                Name = "Roger"
            });
            rabbitHat.Add(new Rabbit {
                Name = "Thumper"
            });

            Rabbit firstRabbit = rabbitHat.Retrieve();  // pull rabbit

            Console.WriteLine(firstRabbit.Name);
        }