[zeromq-dev] [ZFL] list class
Martin Hurton
hurtonm at gmail.com
Thu Oct 14 20:25:04 CEST 2010
Sending v2. There is no function to iterate down the list now; you can
only ask for head and add an item at the tail.
Should be sufficent to implement message queues.
Comments welcome.
- mh
typedef struct _zfl_list zfl_list_t;
// Create a new linked list.
zfl_list_t *
zfl_list_new ();
// Destroy the list and deallocate all items.
void
zfl_list_destroy (zfl_list_t **self_p);
// Return the first item. The item is removed from the list.
// The function returns NULL if the list is empty.
void *
zfl_list_front (zfl_list_t *self);
// Add item at the end of the list. The function returns the item added.
void
zfl_list_append (zfl_list_t *self, void *value);
// Remove the item from the list.
void
zfl_list_remove (zfl_list_t *self, void *value);
// Return the number of items in the list.
size_t
zfl_list_size (zfl_list_t *self);
// Selftest.
void
zfl_list_test ();
On Thu, Oct 14, 2010 at 5:00 PM, Pieter Hintjens <ph at imatix.com> wrote:
> On Thu, Oct 14, 2010 at 2:59 PM, Martin Hurton <hurtonm at gmail.com> wrote:
>
>> zfl_list_destroy (zfl_list_t *self);
>
> ZFL passes **self to destructors and nullifies the pointer after.
>
>> // Insert the element at the end of the list.
>> void
>> zfl_list_append (zfl_list_t *self, void *val);
>
> Doesn't return new element? I'd use zfl_list_item_t, it's shorter.
> Also, maybe simple 'after' and 'before' for insertion.
>
>> // Insert the element after a given element. Returns new element.
>> zfl_list_element_t *
>> zfl_list_insert_after (zfl_list_element_t *el, void *val);
>
> So:
>
>> zfl_list_insert (zfl_list_item_t *item, void *value);
>
>> // Return the value of the element.
>> void *
>> zfl_list_value (zfl_list_t *self);
>
> This is mixing the APIs for zfl_list and zfl_list_item IMO. Either
> make one class where the list items are hidden, or make two classes
> each with their respective methods.
>
>> size_t
>> zfl_list_len (zfl_list_t *self);
>
> In general, don't use abbreviations for methods, just find short
> names. So 'size' rather than 'len'.
>
> So this is the first step towards making a zfl_queue class for
> messages? That'll be nice to use in devices...
>
> -
> Pieter
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
More information about the zeromq-dev
mailing list