By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,244 Members | 1,772 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,244 IT Pros & Developers. It's quick & easy.

C#-APP/FORM: Determining the most efficient Collections to store a wordlist

P: 15
Programming Language: C#, .NET Framework 3.5
In this context, Form and App both describe a Microsoft Windows desktop application i'm creating.

I'm creating a wordlist generator. I need to be able to store each word in an efficient manner. I don't need to search the collection or modify it - I just need to be able to write every entry in the collection back into a text file. So, what is the best collection to use? I heard ArrayLists were not efficient. String arrays would consume a lot of resources (which I DO NOT want happening). HashTables have a key/pair value which I don't need, although the key could be the index (but that would not be the MOST EFFICIENT). Is there an efficient Collection to manage a list of hundreds of thousands of words?
Aug 15 '08 #1
Share this Question
Share on Google+
8 Replies


10K+
P: 13,264
Where did you hear that ArrayList is note efficient?
Aug 15 '08 #2

P: 15
around the web. anybody have an answer?
Aug 15 '08 #3

Expert 100+
P: 427
Well i never had any serious performance issues with array lists, but you could look at collections...

Do you want a data structure from the framework? If not you could use a linked list, thats pretty fast and only uses as much space as is needed.
Aug 15 '08 #4

Plater
Expert 5K+
P: 7,872
How about a generic?
List<string> would be pretty good I would think. It's like an ArrayList except boxed especially for strings?
Aug 15 '08 #5

Expert 100+
P: 427
How about a generic?
List<string> would be pretty good I would think. It's like an ArrayList except boxed especially for strings?
is the framework's list the same as a linked list?
Aug 15 '08 #6

Plater
Expert 5K+
P: 7,872
Well I would hope that the frameworks implementation would be less costly then having to use unmanaged code in a managed environment?
For what it's worth, there's also:
LinkedList<string>
Aug 15 '08 #7

P: 15
So if I used a LinkedList<string> it wouldnt use too much memory generating millions of strings?
Aug 15 '08 #8

Expert 100+
P: 427
So if I used a LinkedList<string> it wouldnt use too much memory generating millions of strings?
yeah kind of, that depends if you implement your own linked list it might.
The microsoft implementation SHOULD be built to dynamically assign memory so it would only use as much as it needs.

If it is millions of strings, have a fixed size collection of like 1000 or whatever and write to your file everytime it is full.

If you have that many instances it doesn't matter what datastructure you use, it will cost a lot of memory.
Aug 15 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.