Exemplo n.º 1
0
        /// <summary>
        /// Compare two events
        /// </summary>
        /// <param name="a">First event</param>
        /// <param name="b">Second event</param>
        /// <returns></returns>
        public static int Compare(Event a, Event b)
        {
            // check for nulls
              if(a == null)
            return b == null ? 0 : -1;
              else if (b == null)
            return 1;

              if (a.Time == b.Time)
            return 0;
              else
            return a.Time > b.Time ? 1 : -1;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Add an event to the queue
 /// </summary>
 /// <param name="evt"></param>
 public void Enqueue(Event evt)
 {
     Simulation.CollectStats();
       Queue.Enqueue(evt);
       MaxQueueLength = Math.Max(Queue.Count, MaxQueueLength);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Put a new event into the event queue
        /// </summary>
        /// <param name="evt">Event</param>
        public static void RegisterEvent(Event evt)
        {
            if (evt != null)
              {
            // traverse the queue and find the first element bigger than current
            var idx = 0;
            foreach (var curr in EventQueue)
            {
              // there's a place to add the event to
              if(curr.Time > evt.Time)
              {
            EventQueue.Insert(idx, evt);
            return;
              }
              idx++;
            }

            EventQueue.Add(evt);
              }
        }