public Cert(HalfEdge e, double tc, double tv) { edge = e; timeViolated = tv; timeCreated = tc; internalCert = false; key = null; }
public void ChangePriority(PQKey key, double newP) { double oldP = list[key.loc].priority; list[key.loc].priority = newP; if (oldP > list[key.loc].priority) { int ci = key.loc; while (ci > 0) { int pi = (ci - 1) / 2; // parent index if (list[ci].CompareTo(list[pi]) >= 0) { break; // child item is larger than (or equal) parent so we're done } PQWrapper <T> tmp = list[ci]; list[ci] = list[pi]; list[pi] = tmp; list[ci].key.loc = ci; list[pi].key.loc = pi; ci = pi; } } else { int pi = key.loc; // parent index. start at front of pq int li = list.Count - 1; while (true) { int ci = pi * 2 + 1; // left child index of parent if (ci > li) { break; // no children so done } int rc = ci + 1; // right child if (rc <= li && list[rc].CompareTo(list[ci]) < 0) // if there is a rc (ci + 1), and it is smaller than left child, use the rc instead { ci = rc; } if (list[pi].CompareTo(list[ci]) <= 0) { break; // parent is smaller than (or equal to) smallest child so done } PQWrapper <T> tmp = list[pi]; list[pi] = list[ci]; list[ci] = tmp; // swap parent and child //Adjust key vals list[ci].key.loc = ci; list[pi].key.loc = pi; pi = ci; } } }