コード例 #1
0
 public HeapItem UpdateKey(HeapItem heapItem, int key)
 {
     if (heapItem != null && heapItem.HeapParent == this && heapItem.HeapPosition < Length && heapItem.HeapKey != key)
     {
         heapItem.HeapKey = key;
         MinHeapify(heapItem.HeapPosition);
     }
     return(heapItem);
 }
コード例 #2
0
 public HeapItem AddItem(HeapItem item, int key)
 {
     if (item != null)
     {
         int len = Length;
         item.HeapKey      = key;
         item.HeapParent   = this;
         item.HeapPosition = len;
         _heap.Add(item);
         Length++;
         MinHeapify(len);
     }
     return(item);
 }
コード例 #3
0
        public void Clear(bool full = true)
        {
            HeapItem heapItem = null;
            var      index    = 0;

            for (int i = 0; i < Length; i++)
            {
                if (heapItem != null)
                {
                    heapItem.HeapPosition = -1;
                    heapItem.HeapParent   = null;
                }
                index++;
            }

            Length = 0;
            if (full)
            {
                _heap.Clear();
            }
        }