NEDM64 Posted June 19, 2008 at 09:49 PM Report Share #192309 Posted June 19, 2008 at 09:49 PM Boas, qual é o equivalente ao vector<isto ou aquilo> da STL do C++? Não, não quero uma lista. Nas listas, posso usar, por exemplo: List<int> x; ... x.at(23); ? Tenho de fazer include de alguma coisa para usar listas? E (se houver), equivalente do vector? Link to comment Share on other sites More sharing options...
Triton Posted June 19, 2008 at 09:57 PM Report Share #192313 Posted June 19, 2008 at 09:57 PM http://msdn.microsoft.com/en-us/library/system.collections.generic.aspx http://msdn.microsoft.com/en-us/library/system.collections.arraylist.aspx <3 life Link to comment Share on other sites More sharing options...
Betovsky Posted June 19, 2008 at 11:09 PM Report Share #192334 Posted June 19, 2008 at 11:09 PM List<int> x; ... x.at(23); Provavelmente queres algo tipo List<int> x; ... x[23]; "Give a man a fish and he will eat for a day; Teach a man to fish and he will eat for a lifetime. The moral? READ THE MANUAL !" Sign on a computer system consultant's desk Link to comment Share on other sites More sharing options...
NEDM64 Posted June 20, 2008 at 02:43 PM Author Report Share #192407 Posted June 20, 2008 at 02:43 PM Provavelmente queres algo tipo List<int> x; ... x[23]; OK, mas eu em C++ aprendi que não se deve usar essa cena dos , e usar .at(i), ás vezes, causava segmentation fault, no C# tem mal? Mas o que eu queria mesmo, era um container que não tivesse "performance penality" para aceder aos vários elementos, como são os vectores em C++. Em C#, há alguma maneira de fazer isto sem ser com arrays? Ou alguma maneira de aumentar o tamanho da memória alocada automaticamente quando inserimos um elemento, tipo, como o push_back() do C++? Link to comment Share on other sites More sharing options...
Triton Posted June 20, 2008 at 05:03 PM Report Share #192433 Posted June 20, 2008 at 05:03 PM OK, mas eu em C++ aprendi que não se deve usar essa cena dos , e usar .at(i), ás vezes, causava segmentation fault, no C# tem mal? Se acederes a uma posição que não existe vais obter uma excepção ou um erro. Mas o que eu queria mesmo, era um container que não tivesse "performance penality" para aceder aos vários elementos, como são os vectores em C++. Em C#, há alguma maneira de fazer isto sem ser com arrays? Ou alguma maneira de aumentar o tamanho da memória alocada automaticamente quando inserimos um elemento, tipo, como o push_back() do C++? Já te dei um link para um ArrayList que faz o que pretendes... <3 life Link to comment Share on other sites More sharing options...
NEDM64 Posted June 20, 2008 at 07:59 PM Author Report Share #192465 Posted June 20, 2008 at 07:59 PM Obrigado, mas não estava a ver bem o "Container". Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now