473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Queue<> implements ICollection but not ICollection<>?

Am I missing something here? It looks like the generic Queue<T> implements
Enumerable<T> and ICollection but not ICollection<T>. (I want to use it in
an interface that wants an ICollection<T>.)

Is there a reason for this, or is it just an oversight in .NET 2.0?

Is there a computationally easy way to cast/convert a Queue<T> to an
ICollection<T>?
May 10 '06 #1
3 2562
Dave,

Unfortunately, it looks like it was overlooked. Quite pathetic in my
opinon.

I would register a bug over at the Product Feedback page.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dave Booker" <db******@newsgroup.nospam> wrote in message
news:D8**********************************@microsof t.com...
Am I missing something here? It looks like the generic Queue<T>
implements
Enumerable<T> and ICollection but not ICollection<T>. (I want to use it
in
an interface that wants an ICollection<T>.)

Is there a reason for this, or is it just an oversight in .NET 2.0?

Is there a computationally easy way to cast/convert a Queue<T> to an
ICollection<T>?

May 10 '06 #2
Could be wrong, but ICollection<T> would make a queue more like a list then
a queue. Queue does not have a Remove(item) method, but ICollection<T>
does. So that would wreck the symantics of Queue which only have Enqueue
and Dequeue to add item to end and remove item from top - so Remove(item)
does not fit with Queue.

--
William Stacey [MVP]

"Dave Booker" <db******@newsgroup.nospam> wrote in message
news:D8**********************************@microsof t.com...
| Am I missing something here? It looks like the generic Queue<T>
implements
| Enumerable<T> and ICollection but not ICollection<T>. (I want to use it
in
| an interface that wants an ICollection<T>.)
|
| Is there a reason for this, or is it just an oversight in .NET 2.0?
|
| Is there a computationally easy way to cast/convert a Queue<T> to an
| ICollection<T>?
May 10 '06 #3
OK, I see what you mean: I.e., despite the linguistic similarities,
ICollection<> is NOT a generic ICollection.

Well, I would like to have a generic ICollection. And surely there's a use
for what they decided to call the ICollection<>, but probably under a
different name? I guess I'll leave it to the far more enlightened architects
to clear this up....

"Greg Young" wrote:
This is not a bug it is by design and it is documented.

From: http://msdn2.microsoft.com/en-US/library/92t2ye13.aspx

"Some collections that limit access to their elements, like the Queue class
and the Stack class, directly implement the ICollection interface."

If you look, the interfaces are also very different from each other in what
they include. The generic one includes methods such as ...

Add, Remove, Clear

Which do not exist on the non-generic ICollection.

I would agree that the terminology is a problem but the class is implemented
as it should be.

Cheers,

Greg Young
MVP - C#
"Dave Booker" <db******@newsgroup.nospam> wrote in message
news:D8**********************************@microsof t.com...
Am I missing something here? It looks like the generic Queue<T>
implements
Enumerable<T> and ICollection but not ICollection<T>. (I want to use it
in
an interface that wants an ICollection<T>.)

Is there a reason for this, or is it just an oversight in .NET 2.0?

Is there a computationally easy way to cast/convert a Queue<T> to an
ICollection<T>?


May 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Luca | last post by:
I have the need of a container of integers showing both the characteristics of an associative container (all integer elements different from each other) and the FIFO behaviour. Do you know if...
7
by: Dave | last post by:
Hello all, I'm pondering why the default underlying container for std::priority_queue<> is std::vector<>. It would seem that inserts are liable to happen anywhere, which would make std::list<>...
11
by: Charles L | last post by:
I have read that the inclusion of <fstream.h> makes the inclusion of <iostream.h> unnecessary. Is this correct? Charles L
1
by: verec | last post by:
Last week I asked here how I could detect that a T was polymorphic, and received very thoughtful and useful replies that I used straight away. Thanks to all who answered. This week, it turns...
5
by: tobbe | last post by:
Hi Im trying to load a XmlDataDocument with the following xml: <ROOT> <NAME> &LT; &AMP; &GT; " '</NAME> </ROOT> And i know I have a entity problem here, but i cant find any solution for...
22
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the...
17
by: Rainer Queck | last post by:
Hi NG, one more question about thread safety of generic lists. Let's assume a generic list: List<MyTyp> aList = new List<MyType>(); Would it be a problem if one thread removes elements from...
3
by: Alex Vinokur | last post by:
Is using memcpy() with queue<char> safe? ------ C++ code ------ #include <cstring> #include <iostream> #include <queue> using namespace std; int main() {
2
by: Richard Maher | last post by:
Hi, I'm trying to use the Visibility Style attribute for a Div to effectively PopUp a lightweight window with some additional context-sensitive information, when a user mouses over a given...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.