Пример #1
0
 public IEnumerable <IJob> Pop(Predicate <IJob> predicate)
 {
     lock (queue)
     {
         IEnumerable <IJob> matchedJobs = queue.Where(job => predicate(job));
         foreach (IJob job in matchedJobs)
         {
             queue.Remove(job);
         }
         return(matchedJobs);
     }
 }
Пример #2
0
        /// <summary>
        /// UpdateStateIfPathBetter.
        /// </summary>
        /// <param name="current">to check</param>
        public void UpdateStateIfPathBetter(State <T> current)
        {
            // find the state at the open list
            State <T> state = openList.Where(elem => current.Equals(elem)).First();

            double costOfState = updatedStates[state].Value;

            // if the currend cost is better, update his cost
            if (current.Cost < costOfState)
            {
                updatedStates[state] = new KeyValuePair <State <T>, double>
                                           (current.CameFrom, current.Cost);
                openList.UpdatePriority(state, (float)current.Cost);
            }
        }