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>? 3 2576
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.co m
"Dave Booker" <db******@newsg roup.nospam> wrote in message
news:D8******** *************** ***********@mic rosoft.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>?
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******@newsg roup.nospam> wrote in message
news:D8******** *************** ***********@mic rosoft.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>?
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******@newsg roup.nospam> wrote in message news:D8******** *************** ***********@mic rosoft.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>? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 there is a ready-made container for that or if I have
to use - for example - a set<int> and produce by myself FIFO
behaviour, or maybe I can use a queue<int> adding code for preventing
the insertion od duplicate integers
Thank you
|
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<> a superior alternative. Why factors am I not
considering here? Why in the general case would std::vector<> be best?
Thanks,
Dave
|
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
|
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 out that detecting whether T is polymorphic clashes with
a new requirement, that T be allowed to not be complete.
Last week, this code used to compile:
|
by: tobbe |
last post by:
Hi
Im trying to load a XmlDataDocument with the following xml:
<ROOT>
<NAME> < & > " '</NAME>
</ROOT>
And i know I have a entity problem here, but i cant find any solution for
it. The problem is that i recive this from external source and cant
| |
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 document and
closes it with the following code:
<body onload="window.print(); window.close();">
This works correctly (or at least the way I expect it to work under MS
Internet Explorer, but it cuases Netscape to "crash"
|
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 the list like
MyTyp x = aList;
aList.Remove(x);
|
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()
{
|
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 field(s). The popping-up seems
to work just fine; it's the tearing down that's giving me grief. If I stick
a onmouseout event on the same input field that caused the
onmouseover/pop-up, it starts to flicker 'cos the <divis placed for
esthetically...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |