Jay Bazuzi's personal blog: An attempt at an immutable Queue
Eric said he will write about an immutable queue implementation. I really like the way the immutable stack turned out, essentially using references between Stack<> objects to implement a linked list, but I couldn't figure out a similarly elegant way to do the same thing for Queue. Maybe people who are more clever will come up with something better, but I just had each Queue<> object contain a list of references to elements.
I wrote once in C# 2.0, using an array to store the elements. The code would be cleaner if I used a List<>, but then I would be harder to verify immutability.
Read full article from Jay Bazuzi's personal blog: An attempt at an immutable Queue
No comments:
Post a Comment