473,770 Members | 6,506 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does 2005 C# have STL?

Does the 2005 release of Visual Studio provide either STL (the C++ Standard
Template Library) or an equivalent for C#? I am most interested in the 2005 C#
equivalent of std::vector.
Jan 16 '06 #1
6 2506
Peter Olcott <ol****@att.net > wrote:
Does the 2005 release of Visual Studio provide either STL (the C++ Standard
Template Library) or an equivalent for C#? I am most interested in the 2005 C#
equivalent of std::vector.


Look at System.Collecti ons.Generic.Lis t<T>
That's the closest equivalent, I believe.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 16 '06 #2
Peter,
Does the 2005 release of Visual Studio provide either STL (the C++
Standard Template Library) or an equivalent for C#? I am most interested
in the 2005 C# equivalent of std::vector.


In general, there are several classes in C# that provide the functionality
of std::vector. However, which to use depends on what storage model and
behavior you want to need. If you need fast lookup of random data in the
"vector", you might want to use:

System.Collecti ons.Specialized .HybridDictiona ry

If your application needs a plain vanilla queue-like behavior, you might
start with:

System.Collecti ons.Queue

If your application needs a plain vanilla array-like behavior where you
iterate over the elements, you might use:

System.Collecti ons.ArrayList

If your application needs the list to be sorted, you might use:

System.Collecti ons.SortedList

There are other collection, link-list, etc. classes, but I am sure you get
the idea. The one you pick depends on the characteristics that are most
important to the application. Start in the System.Collecti ons namespace. I
hope that helps.

Regards,

Randy
Jan 16 '06 #3
Yeah, but, they all changed with 2005 to have generics too right?

"Randy A. Ynchausti" <ra************ *@msn.com> wrote in message
news:OM******** ******@TK2MSFTN GP14.phx.gbl...
Peter,
Does the 2005 release of Visual Studio provide either STL (the C++ Standard
Template Library) or an equivalent for C#? I am most interested in the 2005
C# equivalent of std::vector.


In general, there are several classes in C# that provide the functionality of
std::vector. However, which to use depends on what storage model and behavior
you want to need. If you need fast lookup of random data in the "vector", you
might want to use:

System.Collecti ons.Specialized .HybridDictiona ry

If your application needs a plain vanilla queue-like behavior, you might start
with:

System.Collecti ons.Queue

If your application needs a plain vanilla array-like behavior where you
iterate over the elements, you might use:

System.Collecti ons.ArrayList

If your application needs the list to be sorted, you might use:

System.Collecti ons.SortedList

There are other collection, link-list, etc. classes, but I am sure you get the
idea. The one you pick depends on the characteristics that are most important
to the application. Start in the System.Collecti ons namespace. I hope that
helps.

Regards,

Randy

Jan 16 '06 #4
On Mon, 16 Jan 2006 15:11:40 -0600, "Peter Olcott" <ol****@att.net >
wrote:
Does the 2005 release of Visual Studio provide either STL (the C++ Standard
Template Library) or an equivalent for C#? I am most interested in the 2005 C#
equivalent of std::vector.

VS 2005 is .NET 2.0 so it has generics. The closest to std::vector<t>
is System.Collecti ons.Generics.Li st<T> which is contiguous storage,
random acces with an indexer ([]) and easy to add new items at the end
but not in the middle. THere are other containers in
System.Collecti ons.Generics which you might want to look at as well,
depending on your exact requirements.

rossum

--

The ultimate truth is that there is no ultimate truth
Jan 16 '06 #5
Peter,
Yeah, but, they all changed with 2005 to have generics too right?


There is a new namespace, System.Collecti ons.Generic. The Generics flavor
of the collection classes mainly provide a higher degree of type safety.
For example, let's say we want to have a dictionary that uses an integer as
the key and a DateTime as the value. The non-Generic version might be coded
as:

System.Collecti ons.Specialized .HybridDictiona ry x = new
System.Collecti ons.Specialized .HybridDictiona ry();
x.Add(1, DateTime.Now);
x.Add("Hello", "World"); // compiles and runs without errors

The non-generic version allows the wrong type of data to be added to the
collection at run-time. Also note that there are no compile-time issues.
The generics version won't allow you to even compile your application:

System.Collecti ons.Generic.Dic tionary<int, DateTime> y = new
System.Collecti ons.Generic.Dic tionary<int, DateTime>();
y.Add(1, DateTime.Now);
y.Add("Hello", "World"); // compiler error 1) can't convert string to int
and 2) can't convert string to DateTime

So one benefit of Generics is the type safety. However, there are simple
ways to guarantee type safety and use the non-generic incantations of the
collections.

Regards,

Randy
Jan 16 '06 #6
Randy A. Ynchausti <ra************ *@msn.com> wrote:
Yeah, but, they all changed with 2005 to have generics too right?


There is a new namespace, System.Collecti ons.Generic. The Generics flavor
of the collection classes mainly provide a higher degree of type safety.


Well, type-safety *and* performance. If you create an ArrayList and
call Add ((byte)10) to it a million times, you'll use up a *lot* more
memory than using List<byte>.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 17 '06 #7

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

Similar topics

2
14169
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip Smarty-2.6.7.tar.gz on a system running WindowsXP SP2. Apache and PHP tested out fine. After adding Smarty, I ran the following http://localhost/testphp.php
54
3979
by: seberino | last post by:
Many people I know ask why Python does slicing the way it does..... Can anyone /please/ give me a good defense/justification??? I'm referring to why mystring gives me elements 0, 1, 2 and 3 but *NOT* mystring (5th element). Many people don't like idea that 5th element is not invited. (BTW, yes I'm aware of the explanation where slicing
1
1641
by: jmespinosabaviera | last post by:
1) Does visual studio standard 2005 include visual basic ?. 2) What difference is there between the visual studio standard 2005 and the professional version ? 3) What difference is there between the visual studio standard 2005 and the express version ? 4) How much does visual studio standard 2005 cost ?
7
2928
by: Nalaka | last post by:
Hi, I created a sinple web service that returns a dataSet. Then I created a client program that uses this web service (that returns the Dataset). My question is, how did the client figure out to create a "DataSet" as the return type from the webservice?
1
12317
by: ME | last post by:
I was running into a problem with the DataGridView while binding it to an object Collection. I got it working and I thought others might like to know how. -------------- Problem ------------- The grid was bound to a simple object collection. The object contained string and decimal properties, nothing to fancy. When an item was added to the collection I would databind as follows (this happened on each item "Add"):
14
4863
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it can be done using the designer but I intentionally don't want to use that. The one reason is that you cannot change the code generated by the designer. The other could be that you have more free hand and control to design your GUI. 2....
3
8309
by: Nick Gilbert | last post by:
Hi, In my VS.NET 2005, if I choose Build Clean Solution, the BIN folder is not touched. Shouldn't it delete all the dll and pdb files in that folder first? Instead, I'm finding I have to do it manually. Also, when I change from Debug to Release, all the pdb files remain in the bin folder. Shouldn't these be deleted automatically? Please let me know what the "Clean Solution" is supposed to do (if it's
0
1007
by: ankit.saxena | last post by:
Hi, I have a COM DLL (created using VC++ 6) that has a a few modules declared under its type library. When I add a reference to this DLL in my Visual Basic 2005 project, all classes and enums appear but the I am unable to see (and use) the module functions. The object browser does not show these modules, nor does the code compile when I try accessing the module methods. I used TlbImp and noticed that when I create the interop assembly...
0
2008
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ((string)(this.GetPropertyValue("Address1")));
1
2162
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
I have a web server 32 bit and SQL server 2005 64bit . Does msdtc support SQL server 2005 64bit with web server 32 bit?
0
9591
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, 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...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9869
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 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...
0
8883
agi2029
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...
0
6676
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();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3970
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
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
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...

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.