Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 public HeapNode()
 {
     Object     = null;
     Importance = 0.0f;
 }
Ejemplo n.º 6
0
 public HeapNode(HeapNode node)
 {
     Object     = node.Object;
     Importance = node.Importance;
 }
Ejemplo n.º 7
0
 public HeapNode(ILabelled obj, float importance)
 {
     Object     = obj;
     Importance = importance;
 }