Re: [Libclc-developers] Introducing the double linked list interface
Status: Planning
Brought to you by:
augestad
|
From: Michael B.A. <mb...@io...> - 2003-03-18 08:14:47
|
On Mon, 17 Mar 2003 19:37:01 -0500 Bryan Donlan <bd...@bd...> wrote: > > typedef struct CLC_DL_NODE > > I don't think struct of typedef names should be uppercase. IMO, only enums and > #defines should be uppercase. I second that. It appears we need a style document or a consistent codebase to model the code after. > > CLC_DL_NODE *clc_dl_FindFirst(CLC_DL_LIST *list, > > int type, > > size_t size, > > void *find, > > int (*cmp)(int typekey, > > const void *datakey, > > int typenode, > > const void *datanode), > > int dir, > > CLC_DL_SEARCH_DATA *srch); This is far too complicated. Also these callback interfaces are less pleasant than a simple iterator interface because you frequently operate on variable on the stack. I would just have an iterate function that initializes the search context object and a next object that returns each element. I don't see the advantage of returning the first element with the initial call. It's a little awkward programatically actually. Incedentally the Linux kernel uses a clever list implementation. The clever part probably wouldn't go over too well here but the basic idea of a circular doublely linked list could be extended to provide the traditional interface. The best description of that list ADT that I have seen is in the Linux Device Drivers book which can be read online here: http://www.xml.com/ldd/chapter/book/ch10.html#t5 The list_head could be adapted to include a void *data pointer I suppose. That might make a nice doublely linked list. Mike -- A program should be written to model the concepts of the task it performs rather than the physical world or a process because this maximizes the potential for it to be applied to tasks that are conceptually similar and, more important, to tasks that have not yet been conceived. |