public void Insert(ILabelled obj, float importance) { if (m_Size == m_Capacity) { Resize(2*m_Size); } var i = m_Size++; var node = new HeapNode(obj, importance); node.Object.Token = i; nodes[i] = node; UpHeap(i); }
public void Insert(ILabelled obj, float importance) { if (m_Size == m_Capacity) { Resize(2 * m_Size); } var i = m_Size++; var node = new HeapNode(obj, importance); node.Object.Token = i; nodes[i] = node; UpHeap(i); }
public void Update(ILabelled obj, float importance) { var i = obj.Token; Debug.Assert(i <= m_Size, "WARNING: Attempting to update past end of heap!"); Debug.Assert(i != NOT_IN_HEAP, "WARNING: Attempting to update object not in heap!"); var oldImport = nodes[i].Importance; nodes[i].Importance = importance; if (importance < oldImport) { DownHeap(i); return; } UpHeap(i); }
public HeapNode() { Object = null; Importance = 0.0f; }
public HeapNode(HeapNode node) { Object = node.Object; Importance = node.Importance; }
public HeapNode(ILabelled obj, float importance) { Object = obj; Importance = importance; }