Exemple #1
0
        public VaccAssigner Vaccinate()
        {
            var prevHead = Head;

            Head = Head?.Next;

            return(prevHead);
        }
Exemple #2
0
 public void Add(VaccAssigner newPerson)
 {
     if (Next is null)
     {
         Next = newPerson;
         return;
     }
     if (Next.VacCat.CompareTo(newPerson.VacCat) > 0)
     {
         var temp = Next;
         Next      = newPerson;
         Next.Next = temp;
         return;
     }
     Next.Add(newPerson);
 }
Exemple #3
0
 public void RegisterPerson(T1 newPerson, VacCat vacCat)
 {
     if (Head == null)
     {
         Head = new VaccAssigner(newPerson, vacCat);
         return;
     }
     if (Head.VacCat.CompareTo(vacCat) > 0)
     {
         Head = new VaccAssigner(newPerson, vacCat)
         {
             Next = Head
         };
         return;
     }
     if (Head.Next is null)
     {
         Head.Next = new VaccAssigner(newPerson, vacCat);
         return;
     }
     Head.Add(new VaccAssigner(newPerson, vacCat));
 }
Exemple #4
0
        public T1[] VaccinateWholeCat()
        {
            if (Head is null)
            {
                return(null);
            }

            var cat          = Head.VacCat;
            var vaccCatCount = 0;

            for (var curr = Head; curr != null; curr = curr.Next) // if head is null -> skip for_loop
            {
                if (curr.VacCat == cat)
                {
                    vaccCatCount++;
                }
            }
            var vaccinated = new T1[vaccCatCount];

            var cnt = 0;

            for (var curr = Head; curr != null; curr = curr.Next)
            {
                if (curr.VacCat == cat)
                {
                    vaccinated[cnt] = (T1)curr.Person;
                    cnt++;
                }
            }
            Head.Remove(cat);
            if (Head.VacCat == cat)
            {
                Head = Head.Next;
            }

            return(vaccinated);
        }