This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Improve std::sort over std::array<T, N> for small values of N‏


I have developed a small library to complete std::sort. Basically, the 
idea is to use specific decicated algorithms for a small number of 
values when that number of values is known at compile time. You can 
find the library here: https://github.com/Morwenn/cpp-sort

When given an std::array, the sort function of the library uses a specific 
sorting algorithm (based on sorting networks) for the given number of 
values if it has one and falls back to std::sort if it doesn't. I 
believe that it could be possible to add an overload to the 
implementation of std::sort which would take instances of 
std::array<T, N>::iterator and use a specific sorting algorithm 
for small values of N. It would incur no runtime overhead and would 
allow to sort small arrays for "free" instead of using the general 
purpose version of std::sort which sometimes feel overkill for the job.

Would you be interested in such an optimization for libstdc++? 		 	   		  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]