Пример #1
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);
                }
            }
        }