Changeset 1844:eaa5f5b855f7 in lemon-0.x for lemon/radix_sort.h
- Timestamp:
- 12/03/05 19:15:43 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2403
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/radix_sort.h
r1833 r1844 255 255 template <typename Value> 256 256 unsigned char valueByte(Value value, int byte) { 257 return *((unsigned char *)(&value) +byte);257 return value >> (std::numeric_limits<unsigned char>::digits * byte); 258 258 } 259 259 … … 366 366 bool dir = true; 367 367 std::copy(first, last, buffer); 368 for (int i = 0; i < sizeof(Value); ++i) {368 for (int i = 0; i < (int)sizeof(Value); ++i) { 369 369 if (dir) { 370 counterIntroSort(buffer, buffer + length, buffer + length, 371 i, functor); 370 counterIntroSort(buffer, buffer + length, buffer + length, i, functor); 372 371 } else { 373 counterIntroSort(buffer + length, buffer + 2 * length, buffer, 374 i, functor); 372 counterIntroSort(buffer + length, buffer + 2 * length, buffer, i, functor); 375 373 } 376 374 dir = !dir; … … 426 424 /// in the right order in \c O(n) time. The algorithm sorts the container 427 425 /// by each bytes in forward direction which sorts the container by the 428 /// whole value. This way, let be 429 /// \c c the maximal capacityand \c n the number of the items in426 /// whole value. This way, let be \c c the maximal capacity of the integer 427 /// type and \c n the number of the items in 430 428 /// the container, the time complexity of the algorithm \c O(log(c)*n) 431 429 /// and the additional space complexity is \c O(n).
Note: See TracChangeset
for help on using the changeset viewer.