Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A couple notes:</p> <p><code>List&lt;T&gt;</code> is not optimized for removing the first element. Better would be to sort in the opposite order and take the last element. Or use a <code>Stack&lt;T&gt;</code> or <code>Queue&lt;T&gt;</code>.</p> <p><code>List.Remove(current)</code> is extremely inefficient. You already know the index you want to remove, don't search the entire list for the element.</p> <p>Keeping <code>openNodes</code> sorted by inserting new nodes in the correct location should be much faster than resorting the entire list continually. Skipping the list sort breaks the entire algorithm by removing important invariants. You need to make the sort faster, not skip it.</p> <p>The primary operation you're doing on <code>closedNodes</code> is a presence test, <code>closedNodes.Contains()</code>. Use a data structure that is optimized for that, e.g. <code>Set&lt;T&gt;</code>. Or better yet, put a closed flag field in each node and clear them all at the beginning of each pass. This will be significantly faster than doing a linear search through <code>closedNodes</code> in each iteration.</p> <p>You shouldn't put anything in <code>solutionNodes</code> initially, both <code>mEnd</code> and <code>mStart</code> will get added during the final loop that traverses the path.</p> <p><code>neighborNodes</code> could be an <code>IEnumerable&lt;T&gt;</code> instead of a <code>List&lt;T&gt;</code>, since you never need the entire list at once. Using <code>foreach</code> would also be slightly faster than enumerating the list by index.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload