Skip to content

Small issue with PriorityQueue.Replace #3

Description

@xenoblitz

Hey!

First of all thanks for sharing your pathfinding implementation.

I meet a small issue and was wondering whether it is something I am doing wrong or whether it is in fact a small bug. Sometimes when using the ShortestPathGraphSearch I am getting an error with this class's use of PriorityQueue.Replace(). I did the following small update without getting any adverse effects but am not 100% sure it's legit. Am sharing it here just in case:

public void Replace(V value, P oldPriority, P newPriority){
        if (list.ContainsKey(oldPriority))
        {
            LinkedList<V> v = list[oldPriority]; // <--- this was breaking
            v.Remove(value);

            if (v.Count == 0)
            { // nothing left of the top priority.
                list.Remove(oldPriority);
            }
        }

        Enqueue(value, newPriority);
}

Thanks again,
A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions