Aha! So here are conventional enqueue and dequeue operations in Scheme
(sorry I'm more familiar with scheme than with lisp :) ). The set-car!
and set-cdr! are self-explanatory.
(define (enqueue! queue item)
(let ((new-pair (cons item nil)))
(cond ((empty-queue? queue)
(set-front-ptr
I mean pointers in a purely functional implementation like my lisp
code. The only reason I can think that you'd actually implement with
no pointer mutation in C++ is to improve parallel access in a
mult-threaded system. Then you'd need garbage collection (like smart
pointers for example) to make
> This is a very old technique for representing queues in functional
> languages where you have no assignment. It's called immutable because
> pointers are never changed once they're set.
Gene, thanks a lot for your reply. I'm not sure if I understand what
pointers we're talking about; are they
adityar7 wrote:
> Hi,
>
> Recently I found an algorithm for creating a Queue datatype whose
> objects are immutable. Basically, the algorithm is as follows:
>
> class ImmutableQueue {
> // Assume we know how to create immutable lists
> ImmutableList back;
> ImmutableList front;
> ...
> }
>
hey
can u explain the meaning of immutble queue .
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this g