Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/30/12 11:20:34 (12 years ago)
Author:
spimming
Message:

#1894: fixed assignment issue in BinaryHeap

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/RoutePlanning/HeuristicLab.Algorithms.GraphRouting/3.3/PriorityQueues/BinaryHeap.cs

    r8539 r8540  
    2424        data[i] = new KNElement();
    2525      }
    26       data[0].Key = infimum; // sentinel
     26      data[0].Key = infimum;
    2727      data[capacity + 1].Key = sup;
    2828      supremum = sup;
     
    6060      }
    6161
    62       data[1] = data[size];
     62      data[1].Key = data[size].Key;
     63      data[1].Value = data[size].Value;
     64
    6365      data[size].Key = supremum;
    6466      size--;
     
    8789      int hole = size;
    8890      while ((hole > 1) && (data[hole >> 1].Key.CompareTo(key) == 1)) {
    89         data[hole] = data[hole >> 1];
     91        data[hole].Key = data[hole >> 1].Key;
     92        data[hole].Value = data[hole >> 1].Value;
    9093        hole = hole >> 1;
    9194      }
     
    9598
    9699    public void DecreaseKey(K key, V value) {
    97       int pos = size;
    98       while ((pos > 1) && (data[pos >> 1].Key.CompareTo(key) != 0)) {
    99         pos = pos >> 1;
    100       }
    101       if (data[pos].Key.CompareTo(key) != 0) {
    102         throw new InvalidOperationException("Key not found");
    103       }
    104100      throw new NotImplementedException();
    105101    }
    106 
    107 
    108102
    109103    // reset size to 0 and fill data array with sentinels
Note: See TracChangeset for help on using the changeset viewer.