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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • secutos
    New Member
    • Aug 2008
    • 15

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

    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?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Where did you hear that ArrayList is note efficient?

    Comment

    • secutos
      New Member
      • Aug 2008
      • 15

      #3
      around the web. anybody have an answer?

      Comment

      • cloud255
        Recognized Expert Contributor
        • Jun 2008
        • 427

        #4
        Framework types only?

        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.

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          How about a generic?
          List<string> would be pretty good I would think. It's like an ArrayList except boxed especially for strings?

          Comment

          • cloud255
            Recognized Expert Contributor
            • Jun 2008
            • 427

            #6
            Originally posted by Plater
            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?

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              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<stri ng>

              Comment

              • secutos
                New Member
                • Aug 2008
                • 15

                #8
                So if I used a LinkedList<stri ng> it wouldnt use too much memory generating millions of strings?

                Comment

                • cloud255
                  Recognized Expert Contributor
                  • Jun 2008
                  • 427

                  #9
                  Originally posted by secutos
                  So if I used a LinkedList<stri ng> 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.

                  Comment

                  Working...