Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Collections;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Sztuczna_Inteligencja
- {
- class PriorityQueueF<Element> : IFringe<Element>
- {
- private List<Tuple<int, Element>> queueElements = new List<Tuple<int, Element>>();
- public bool IsEmpty
- {
- get
- {
- return queueElements.Count == 0;
- }
- }
- public Func<Element, int> ToGoalPath { get; set; }
- public void Add(Element element)
- {
- int i = 0;
- for (i = 0; i < queueElements.Count; i++)
- if ((queueElements.Count == 0) || (ToGoalPath(element) <= queueElements[i].Item1) )
- break;
- queueElements.Insert(i, new Tuple<int, Element>(ToGoalPath(element), element));
- }
- public Element Pop()
- {
- return queueElements[0].Item2;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement