323 typedef typename std::iterator_traits<Iterator>::value_type Key; |
323 typedef typename std::iterator_traits<Iterator>::value_type Key; |
324 typedef std::allocator<Key> Allocator; |
324 typedef std::allocator<Key> Allocator; |
325 Allocator allocator; |
325 Allocator allocator; |
326 |
326 |
327 int length = std::distance(first, last); |
327 int length = std::distance(first, last); |
328 Key* buffer; |
328 Key* buffer = allocator.allocate(2 * length); |
329 buffer = allocator.allocate(2 * length); |
|
330 try { |
329 try { |
331 bool dir = true; |
330 bool dir = true; |
332 std::copy(first, last, buffer); |
331 std::copy(first, last, buffer); |
333 for (int i = 0; i < (int)sizeof(Value) - 1; ++i) { |
332 for (int i = 0; i < (int)sizeof(Value) - 1; ++i) { |
334 if (dir) { |
333 if (dir) { |
362 typedef typename std::iterator_traits<Iterator>::value_type Key; |
361 typedef typename std::iterator_traits<Iterator>::value_type Key; |
363 typedef std::allocator<Key> Allocator; |
362 typedef std::allocator<Key> Allocator; |
364 Allocator allocator; |
363 Allocator allocator; |
365 |
364 |
366 int length = std::distance(first, last); |
365 int length = std::distance(first, last); |
367 Key *buffer; |
366 Key *buffer = allocator.allocate(2 * length); |
368 buffer = allocator.allocate(2 * length); |
|
369 try { |
367 try { |
370 bool dir = true; |
368 bool dir = true; |
371 std::copy(first, last, buffer); |
369 std::copy(first, last, buffer); |
372 for (int i = 0; i < (int)sizeof(Value); ++i) { |
370 for (int i = 0; i < (int)sizeof(Value); ++i) { |
373 if (dir) { |
371 if (dir) { |
374 counterIntroSort(buffer, buffer + length, buffer + length, i, functor); |
372 counterIntroSort(buffer, buffer + length, |
|
373 buffer + length, i, functor); |
375 } else { |
374 } else { |
376 counterIntroSort(buffer + length, buffer + 2 * length, buffer, i, functor); |
375 counterIntroSort(buffer + length, buffer + 2 * length, |
|
376 buffer, i, functor); |
377 } |
377 } |
378 dir = !dir; |
378 dir = !dir; |
379 } |
379 } |
380 if (dir) { |
380 if (dir) { |
381 std::copy(buffer, buffer + length, first); |
381 std::copy(buffer, buffer + length, first); |