Re: [PATCH -mm 1/2] sort: Add obj_sort() for sorting all kinds ofrandom-accessible objects

From: Matt Mackall
Date: Fri Sep 12 2008 - 11:58:27 EST



On Fri, 2008-09-12 at 19:55 +0800, Lai Jiangshan wrote:
> current sort can only sort objects on continuous memory,
> but sometimes we need to sort objects on noncontinuous memory,
> this patch provide obj_sort() for this.
>
> Sometimes a C struct(the container of objects, or objects) may be designed
> with some high-level language's semantic meaning. obj_sort() can sort
> for them.
>
> obj_sort() is need for sort pids for cgroup.tasks file.

Ok, if I understand this correctly, your new function basically changes:

cmp(void *a, void *b) to cmp(void *obj, int a, int b)
swap(void *a, void *b, int size) to swap(void *obj, int a, int b)

Since neither function actually looks at the data directly, it seems we
could make a unified sort function with:

cmp(void *base, int a, int b)
swap(void *base, int a, int b, int size)

What is the underlying data structure you're sorting by the way? Years
ago, I wrote a very nice merge sort for linked lists that I never got
around to submitting.

--
Mathematics is the supreme nostalgia of our time.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/