COIN-OR::LEMON - Graph Library

Changeset 2479:221cfaf118a6 in lemon-0.x for lemon/radix_sort.h


Ignore:
Timestamp:
09/28/07 14:42:14 (12 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3318
Message:

Once again bug fix in significant bit calculation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/radix_sort.h

    r2478 r2479  
    138138    Iterator it;
    139139
    140     mask = 0; max_digit = 0;
     140    mask = ~0; max_digit = 0;
    141141    for (it = first; it != cut; ++it) {
    142       while ((mask | functor(*it)) != ~0) {
    143         ++max_digit;
    144         mask <<= 1;
    145         mask |= 1;
    146       }
    147     }
    148     radixIntroSort(first, cut, functor, 1 << max_digit);
    149 
    150     mask = ~0; max_digit = 0;
    151     for (it = cut; it != last; ++it) {
    152       while (mask & functor(*it)) {
     142      while ((mask & functor(*it)) != mask) {
    153143        ++max_digit;
    154144        mask <<= 1;
    155145      }
    156146    }
     147    radixIntroSort(first, cut, functor, 1 << max_digit);
     148
     149    mask = 0; max_digit = 0;
     150    for (it = cut; it != last; ++it) {
     151      while ((mask | functor(*it)) != mask) {
     152        ++max_digit;
     153        mask <<= 1; mask |= 1;
     154      }
     155    }
    157156    radixIntroSort(cut, last, functor, 1 << max_digit);
    158157  }
     
    161160  void radixUnsignedSort(Iterator first, Iterator last, Functor functor) {
    162161
    163     Value mask = ~0;
     162    Value mask = 0;
    164163    int max_digit = 0;
    165164
    166165    Iterator it;
    167166    for (it = first; it != last; ++it) {
    168       while (mask & functor(*it)) {
     167      while ((mask | functor(*it)) != mask) {
    169168        ++max_digit;
    170         mask <<= 1;
     169        mask <<= 1; mask |= 1;
    171170      }
    172171    }
Note: See TracChangeset for help on using the changeset viewer.