[ccan] [PATCH 1/4] queue: Simple queue implementation

David Gibson david at gibson.dropbear.id.au
Wed Jul 9 20:56:18 EST 2014


On Mon, Jul 07, 2014 at 11:13:58PM -0400, Cody P Schafer wrote:
> On Mon, Jul 7, 2014 at 8:51 AM, David Gibson
> <david at gibson.dropbear.id.au> wrote:
> > This new module provides a simple queue implementation as a singly linked
> > (circular) list.
> >
> > Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
> 
> I've been looking for a singly-linked list for places where I don't
> necessarily need a doubly linked one (as provided by ccan/list).
> 
> Would it be possible to format the api for this singly-linked list
> more like the current list.h api?

Well.. what operations would you like to see?  add_after and traverse
are the ones that occur to me quickly.

> More to the point: can't we use this "queue" as a "stack" (or, well, a
> list) just as easily?

You could, but it's certainly not the most natural way to implement a
stack as a linked list.

> Or was the naming purposful so readers of code that uses it would
> actually have an understanding of the intent in using it?

Well, yes, I am intending to emphasise the queue operations over the
implementation.  I'd be perfectly happy re-implementing this in terms
of a more general singly linked list module, but I'm not quite sure
what that would look like.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20140709/74a77ad6/attachment.sig>


More information about the ccan mailing list