Skip to content

recommend flattening heapify and heapifydeletion #3

@laurentopia

Description

@laurentopia

like so:

void Heapify(List<PointData> list, int i) { Profiler.BeginSample("heap i fy"); var parent = (i - 1) / 2; while (parent >= 0 && list[i].FScore < list[parent].FScore) { (list[i], list[parent]) = (list[parent], list[i]); i = parent; parent = (i - 1) / 2; } Profiler.EndSample(); }

void HeapifyDeletion(List<PointData> list, int i) { Profiler.BeginSample("heapify deletion"); int smallest; int l; int r; while (true) { smallest = i; l = 2 * i + 1; r = 2 * i + 2; if (l < list.Count && list[l].FScore < list[smallest].FScore) { smallest = l; } if (r < list.Count && list[r].FScore < list[smallest].FScore) { smallest = r; } if (smallest == i) { break; } (list[i], list[smallest]) = (list[smallest], list[i]); i = smallest; } Profiler.EndSample(); }

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