Пример #1
0
    public Node Dequeue()
    {
        int minIdx = findMinIndex();

        if (minIdx < 0)
        {
            return(null);
        }
        CostedNode item = items[minIdx];

        items.RemoveAt(minIdx);
        return(item.node);
    }
Пример #2
0
    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);
    }