all groups > c# > february 2008 >
You're in the

c#

group:

generic datatypes


Re: generic datatypes Marc Gravell
2/6/2008 1:05:55 PM
c#:
[quoted text, click to view]
Yes [well, 3 references]

[quoted text, click to view]
Yes; this is simply because Queue<T> is a reference-type (class); the
outer queue is *actually* a queue of references; the inner queue is a
queue of integers (since Int32 is a value-type (struct))

To be honest, though, it seems an unlikely scenario to have a nested
queue, since it is highly likely that once you've dequeued each you
are going to simply process the contents and look for the next - are
you sure that a Queue<int[]> (i.e. a queue where each element is an
array of integers) isn't a better option? Just a thought...

Marc
Re: generic datatypes Ben Voigt [C++ MVP]
2/6/2008 5:00:50 PM
[quoted text, click to view]

Or maybe a Queue<int>[], if you need a prioritized group of queues.

[quoted text, click to view]

generic datatypes Tony Johansson
2/6/2008 8:59:34 PM
Hello!

Here I have declared a queue consisting of ints which is a value type.
This is a queue of ints for example 5 int in the queue 6 7 8 4 7
Queue<int> intQueue = new Queue<int>();

Here I have a queue consisting of queue of ints
Each element in the queue is a queue of ints.
Queue<Queue<int>> queueQueue = new Queue<Queue<int>> ();

Now to my question:
Question number 1: Is it right to say for this declaration
Queue<Queue<int>> queueQueue = new Queue<Queue<int>> ();
that
Each element in the queue is a queue of ints. So if the queue have three
elements you have three queues of ints in the queue ?

Question number 2: When you have a queue consisting of queue of ints I
assume that each element is a reference to the queue
of ints is this right understood? If the queue have three elements then each
element is a reference to the queue of ints right?

//Tony

AddThis Social Bookmark Button