lkml.org 
[lkml]   [2008]   [Sep]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH -mm 1/2] sort: Add obj_sort() for sorting all kinds of random-accessible objects
From
Date

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.



\
 
 \ /
  Last update: 2008-09-12 18:01    [W:0.237 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site