Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #5
0
 public HeapNode()
 {
     Object     = null;
     Importance = 0.0f;
 }
Exemple #6
0
 public HeapNode(HeapNode node)
 {
     Object     = node.Object;
     Importance = node.Importance;
 }
Exemple #7
0
 public HeapNode(ILabelled obj, float importance)
 {
     Object     = obj;
     Importance = importance;
 }