Beispiel #1
0
        public void EnqueueCat(string name)
        {
            if (catListHead == null)
            {
                catListHead = new AnimalNode()
                {
                    Name = name, OrderOfEntry = orderOfEntry
                };
                orderOfEntry++;
                return;
            }

            var lastCat = catListHead;

            while (lastCat.Next != null)
            {
                lastCat = lastCat.Next;
            }

            lastCat.Next = new AnimalNode()
            {
                Name = name, OrderOfEntry = orderOfEntry
            };
            orderOfEntry++;
        }
Beispiel #2
0
        public void EnqueueDog(string name)
        {
            if (dogListHead == null)
            {
                dogListHead = new AnimalNode()
                {
                    Name = name, OrderOfEntry = orderOfEntry
                };
                orderOfEntry++;
                return;
            }

            var lastDog = dogListHead;

            while (lastDog.Next != null)
            {
                lastDog = lastDog.Next;
            }

            lastDog.Next = new AnimalNode()
            {
                Name = name, OrderOfEntry = orderOfEntry
            };
            orderOfEntry++;
        }
Beispiel #3
0
        public AnimalNode DequeueCat()
        {
            if (catListHead == null)
            {
                return(null);
            }

            var fifoAnimal = catListHead;

            catListHead = catListHead.Next;
            return(fifoAnimal);
        }
Beispiel #4
0
        public AnimalNode DequeueDog()
        {
            if (dogListHead == null)
            {
                return(null);
            }

            var fifoAnimal = dogListHead;

            dogListHead = dogListHead.Next;
            return(fifoAnimal);
        }