473,372 Members | 1,061 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,372 software developers and data experts.

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 2489
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.Collections.Generic.List<T>
That's the closest equivalent, I believe.

--
Jon Skeet - <sk***@pobox.com>
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.Collections.Specialized.HybridDictionary

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

System.Collections.Queue

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

System.Collections.ArrayList

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

System.Collections.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.Collections 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**************@TK2MSFTNGP14.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.Collections.Specialized.HybridDictionary

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

System.Collections.Queue

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

System.Collections.ArrayList

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

System.Collections.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.Collections 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.Collections.Generics.List<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.Collections.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.Collections.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.Collections.Specialized.HybridDictionary x = new
System.Collections.Specialized.HybridDictionary();
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.Collections.Generic.Dictionary<int, DateTime> y = new
System.Collections.Generic.Dictionary<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.Collections.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.com>
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
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...
54
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...
1
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...
7
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...
1
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 -------------...
14
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...
3
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...
0
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...
0
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 ...
1
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?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.