Re: Singly Linked List in C
- From: arnuld <sunrise@xxxxxxxxxxxxxxx>
- Date: Sat, 09 May 2009 10:21:21 +0500
On Fri, 08 May 2009 10:51:05 +0000, James Kuyper wrote:
arnuld wrote:
A queue - see <http://en.wikipedia.org/wiki/Queue_(data_structure)>.
While a linked list is certainly one way to implement a queue, a
circular buffer (see links on that same page) could be a better
approach, if you can accept a fixed upper limit to the number of
elements in the queue. It avoids the space overhead of having each node
contain a pointer to the next element in the queue, and it avoids the
time overhead associated with allocating and deallocating each node.
Well, it can't happen as I have no idea how many elements in the list
will be, that could be 2 or 100 or 9,222.
BTW, even if the upper size is fixed (say 10,000), then if there only 100
elements then it wouldn't it cause the space overhead for extra 9900
elements (in case of circular buffer) ?
Declaring a parameter to be const can make sense for exactly the same
reasons that declaring any other local variable const might make sense.
I would not consider it objectionable, but I would want to make sure
that you understand that making 'sp' const has nothing to do with
protecting the argument of the function from modification.
Now I understand, that 2nd const will be useful only in case I am passing
the address of the original pointer which is not the case here.
--
www.lispmachine.wordpress.com
my email is @ the above blog.
.
- Follow-Ups:
- Re: Singly Linked List in C
- From: James Kuyper
- Re: Singly Linked List in C
- References:
- Re: Singly Linked List in C
- From: arnuld
- Re: Singly Linked List in C
- From: Ben Bacarisse
- Re: Singly Linked List in C
- From: arnuld
- Re: Singly Linked List in C
- From: Ben Bacarisse
- Re: Singly Linked List in C
- From: arnuld
- Re: Singly Linked List in C
- From: Ben Bacarisse
- Re: Singly Linked List in C
- From: arnuld
- Re: Singly Linked List in C
- From: Barry Schwarz
- Re: Singly Linked List in C
- From: arnuld
- Re: Singly Linked List in C
- From: James Kuyper
- Re: Singly Linked List in C
- From: arnuld
- Re: Singly Linked List in C
- From: James Kuyper
- Re: Singly Linked List in C
- Prev by Date: Re: how to store 1 million integers?
- Next by Date: Re: PREPROCESSING
- Previous by thread: Re: Singly Linked List in C
- Next by thread: Re: Singly Linked List in C
- Index(es):
Relevant Pages
|