Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# containers - vector,. list, queue, stack etc

From the similar titles I see these are probably not available in C#. because they are so basic and useful they must be there but are probably called something else.

In case they are available do they support sort/search/insert/delete/unique etc. - the usual algorithms?

like image 510
s5s Avatar asked Nov 29 '11 01:11

s5s


2 Answers

You're looking for the classes in System.Collections.Generic, as well as LINQ to Objects.

like image 197
SLaks Avatar answered Sep 19 '22 23:09

SLaks


The names are, for the most part, what you guessed them to be. The System.Collections.Generic namespace contains:

  • List class ("vector", "list")
    • See also LinkedList class
  • Queue class ("queue")
  • Stack class ("stack")

Since they all implement the IEnumerable<T> generic interface, you can use extension methods from the Enumerable class with them, including OrderBy/OrderByDescending ("sort") and Distinct ("unique"). Each of the three classes provides its own specific methods for adding and removing elements from the collection.

like image 34
Lance U. Matthews Avatar answered Sep 20 '22 23:09

Lance U. Matthews