Commit Graph

3 Commits

Author SHA1 Message Date
Davidlohr Bueso 5b9df0280a lists: add list sorting routine
We need a list sorting function, just to mention one example user that could
benefit is the lib/tt code to sort columns.

This patch adds list_sort() which uses the Merge Sort algorithm, behaving
nicely in O(nlog(n)), heavily based on the kernel's implementation[1].  The
private data (void *priv) passed to the comparison function as been removed to
adopt a qsort(3)-like syntax, and IMHO we don't really need it anyways.

[1]: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=lib/list_sort.c;h=d7325c6b103f0be078ff3672c35c468ed35738f1;hb=HEAD

[kzak@redhat.com: - use size_t in list_sort()]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-16 12:37:07 +01:00
Karel Zak 85950b68e4 include: fix list.h ifdefs
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-14 15:49:07 +01:00
Karel Zak c391642d0f include: move shlibs/.../list.h to the include/ directory
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-03 15:20:11 +02:00