Пример #1
0
 public QueueTicket(QueueTicket otherQT)
 {
     QueueID        = otherQT.QueueID;
     QueueNumber    = otherQT.QueueNumber;
     QueueLane      = new Lane(otherQT.QueueLane);
     PriorityNumber = otherQT.PriorityNumber;
     this.owner     = otherQT.owner;
     QueueDateTime  = otherQT.QueueDateTime;
     Status         = otherQT.Status;
 }
Пример #2
0
        private int CompareToWithTolerance(QueueTicket item, QueueTicket nextItem)
        {
            //HasHigherPriority comparison is in the perspective of the parameter object

            //next item has higher priority
            if (item.HasHigherPriority(
                    nextItem.PriorityNumber,
                    nextItem.QueueDateTime,
                    this.Tolerance
                    ))
            {
                return(-1);
            }
            //current item has higher priority
            else
            {
                return(1);
            }
        }
Пример #3
0
        /// <summary>
        /// Enqueues a queue ticket to the queue list with priority considerations
        /// </summary>
        /// <param name="newTicket"></param>
        public void EnqueueTicket(QueueTicket newTicket)
        {
            if (QueueList.Count < QueueLane.Capacity &&
                newTicket.QueueLane.LaneID == newTicket.QueueLane.LaneID)
            {
                int indexToInsert = QueueList.FindIndex(
                    item => item.HasHigherPriority(
                        newTicket.PriorityNumber,
                        newTicket.QueueDateTime,
                        Tolerance
                        ));

                if (indexToInsert != -1)
                {
                    QueueList.Insert(indexToInsert, newTicket);
                }
                else
                {
                    //index at end of list
                    QueueList.Add(newTicket);
                }
            }
        }