public Node Dequeue() { int minIdx = findMinIndex(); if (minIdx < 0) { return(null); } CostedNode item = items[minIdx]; items.RemoveAt(minIdx); return(item.node); }
private int findMinIndex() { CostedNode min = null; int idx = -1; for (int i = 0; i < items.Count; i++) { if (min == null) { idx = i; min = items [i]; } else if (items[i].cost <= min.cost) { idx = i; min = items [i]; } } return(idx); }