Пример #1
0
        public void RemoveByIndex(int index)
        {
            if (index < 0 || size == 0)
            {
                throw new ArgumentOutOfRangeException("Index : " + index);
            }
            if (index >= size)
            {
                index = size - 1;
            }

            current = this.head;
            if (index == 0)
            {
                RemoveFront();
            }
            else
            {
                for (int i = 0; i < index - 1; i++)
                {
                    current = current.NextAlarm;
                }
                RemoveAfter(current, current.NextAlarm);
            }
        }
Пример #2
0
        public void AddByIndex(Alarms new_node, int index)
        {
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("Index : " + index);
            }
            if (index > size)
            {
                index = size;
            }

            current = this.head;
            if (size == 0 || index == 0)
            {
                InsertFront(new_node);
            }
            else
            {
                for (int i = 0; i < index - 1; i++)
                {
                    current = current.NextAlarm;
                }
                InsertAfter(current, new_node);
            }
        }
Пример #3
0
 public AlarmsLinkedList(Alarms head, int size, MyContext A)
 {
     this.head  = head;
     this.size  = size;
     this.repoA = A;
     Console.WriteLine("Size " + size);
     PrintAll();
 }
Пример #4
0
 internal void PrintAll()
 {
     num = 0;
     while (head != null)
     {
         Console.WriteLine(num++ + " " + head.stageName + " " + head.Minutes + " " + head.IngredList);
         head = head.NextAlarm;
     }
 }
Пример #5
0
        internal Alarms GetLastNode()
        {
            Alarms temp = head;

            while (temp.NextAlarm != null)
            {
                temp = temp.NextAlarm;
            }
            return(temp);
        }
Пример #6
0
        internal void RemoveFront()
        {
            Alarms temp = this.head;

            this.head = head.NextAlarm;
            head.Head = true;
            repoA.DeleteAlarm(temp);
            repoA.SaveAlarmAsync(head);
            repoA.SaveChangesAsync();
            size--;
        }
Пример #7
0
 internal void InsertFront(Alarms new_node)
 {
     new_node.setNextAlarmInfo(head);
     head                = new_node;
     head.Head           = true;
     head.NextAlarm.Head = false;
     repoA.SaveAlarmAsync(head.NextAlarm);
     repoA.SaveAlarmAsync(head);
     repoA.SaveChangesAsync();
     size++;
 }
Пример #8
0
 public void setNextAlarmInfo(Alarms next)
 {
     if (next != null)
     {
         this.NextAlarm   = next;
         this.NextAlarmId = next.AlarmsId;
     }
     else
     {
         Console.WriteLine(" Next is null. ");
     }
 }
Пример #9
0
 internal void RemoveAfter(Alarms prev_node, Alarms toDelete)
 {
     if (prev_node == null)
     {
         Console.WriteLine("The given previous node Cannot be null");
         return;
     }
     prev_node.setNextAlarmInfo(toDelete.NextAlarm);  //or  prev_node.NextAlarm.NextAlarm;
     repoA.DeleteAlarm(toDelete);
     repoA.SaveAlarmAsync(prev_node);
     repoA.SaveChangesAsync();
     size--;
 }
Пример #10
0
 public void InsertAfter(Alarms prev_node, Alarms new_node)
 {
     if (prev_node == null)
     {
         Console.WriteLine("The given previous node Cannot be null");
         return;
     }
     new_node.setNextAlarmInfo(prev_node.NextAlarm);
     prev_node.setNextAlarmInfo(new_node);
     repoA.SaveAlarmAsync(prev_node);
     repoA.SaveAlarmAsync(new_node);
     repoA.SaveChangesAsync();
     size++;
 }
Пример #11
0
        public Alarms getAlarm(int Index)
        {
            if (Index < 0 || size == 0)
            {
                throw new ArgumentOutOfRangeException("Index : " + Index);
            }
            if (Index >= this.size)
            {
                Index = this.size - 1;
            }

            current = this.head;
            for (int i = 0; i < Index; i++)
            {
                current = current.NextAlarm;
            }
            return(current);
        }
Пример #12
0
 internal void InsertLast(Alarms new_node)
 {
     if (head == null)
     {
         head         = new_node;
         current      = head;
         current.Head = true;
     }
     else
     {
         Alarms lastNode = GetLastNode();
         lastNode.setNextAlarmInfo(new_node);
         current = lastNode.NextAlarm;
         repoA.SaveAlarmAsync(lastNode);
     }
     repoA.SaveAlarmAsync(current);
     repoA.SaveChangesAsync();
     size++;
 }
Пример #13
0
 public Alarms(Stage stageName, double Minutes, string IngredList, Recipe recipe, Alarms next) : this(stageName, Minutes, IngredList)
 {
     setNextAlarmInfo(next);
     this.Recipe = recipe;
 }
Пример #14
0
 public AlarmsLinkedList()
 {
     head = null;
     size = 0;
 }