[ccan] Question on list module

richard -rw- weinberger richard.weinberger at gmail.com
Tue Dec 14 10:51:44 EST 2010


Hello Dave, Kim,

On Tue, Dec 14, 2010 at 12:40 AM, David Collett <david.collett at gmail.com> wrote:
> Hi Richard,
>
> If you require your object to belong to multiple lists *at the same
> time*, you need to include a list_node in your object for each list
> you wish to belong to, just give them different (e.g. descriptive)
> names.

Thats what i thought. :-(
I don't know in how many lists a object exists.
It depends on runtime information.

I'll refactor my program.
Anyway, thanks for your answers!

> Dave
>
> On Tue, Dec 14, 2010 at 10:09 AM, richard -rw- weinberger
> <richard.weinberger at gmail.com> wrote:
>> Hi!
>>
>> I'm using the list module. It is very nice.
>> But now I'm facing a little problem.
>> It seems that a list node can (by design) only be a member of one linked list.
>> In my case i need to have list nodes which are present in many lists.
>>
>> E.g:
>> struct _item {
>>  struct list_node list;
>>  // lots of data
>> };
>> struct _item i1;
>>
>> list_add(&h1, &i1.list);
>> list_add(&h2, &i1.list);
>> ...
>> list_add(&hN, &i1.list);
>>
>>
>> Does anyone know a trick how to achieve this?
>> I really don't want to go back to "void *"-style linked lists...
>>
>> --
>> Thanks,
>> //richard
>> _______________________________________________
>> ccan mailing list
>> ccan at lists.ozlabs.org
>> https://lists.ozlabs.org/listinfo/ccan
>>
>



-- 
Thanks,
//richard


More information about the ccan mailing list